Treat each number as string and make a trie out of it. For the first input
[55,31,312,33], it would look like the following
                                      .
                                    /    \
                                 3/     5\
                               1/  3\    5\
                            31/ 2\   33\  \55
                                   312\
Once we have a trie, just print it out by based on the smallest number
first. In this case, the print would go as follows.

313123355

On Sat, Aug 21, 2010 at 12:53 PM, Nikhil Agarwal
<nikhil.bhoja...@gmail.com>wrote:

> Suppose the test is like:
>
> 21 71 217
> after sorting and msb appending we get: 217 712 217
> sort: 217 217 712
>
> here we have 2 same elements 217 and 217 so we remove the 7 from the
> following logic:
>
> 1.if msb > lsb we delete from the 2nd 217.else
> 2.we delete 7 from 1st one.
>
> so this gives 2121771
>
> if it wud have been 41 200 412->412 200 412->200 412 412
> here we will remove 2 from last one.giving 20041241 instead of 20041412 .
>
> On Sat, Aug 21, 2010 at 12:26 PM, BALARUKESH SIVARAMAN <
> sbalarukesh1...@gmail.com> wrote:
>
>> @Nikhil
>> I am clear with your first 2 algos but not with the change u introduced
>> ie., adding a check. please give a working example....
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Thanks & Regards
> Nikhil Agarwal
> Senior Undergraduate
> Computer Science & Engineering,
> National Institute Of Technology, Durgapur,India
> http://tech-nikk.blogspot.com
> http://beta.freshersworld.com/communities/nitd
>
>
> --
>  You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to