@sunny it will work fine if you have 2 numbers only...but what about the
list...3..4 or 5..or more....then the possible number of combinations will
be  'N!'...where n is the number of digits.......the code will work quite
slowly for larger 'n'.

On Fri, May 27, 2011 at 3:33 PM, Dave <dave_and_da...@juno.com> wrote:

> @Shubham: Try 8, 89, 7. Your algorithm gives 8897, but the right
> answer is 8987.
>
> Dave
>
> On May 27, 1:11 pm, shubham <shubh2...@gmail.com> wrote:
> > check whether these steps work:
> >
> > step 1:
> >         sort the given numbers in the decreasing order based on their
> first
> > digit.
> > step 2:
> >         if two numbers come out to be equal in the above case & both of
> > their next digit exist then sort on the basis of their next digit,
> otherwise
> > the number
> >         whose next digit doesnot exist should be placed before the other
> > number.
> > step 3:
> >        concatenate these numbers.
> >
> > e.g.
> >
> > (0,1,10,100) sorting it gives: 1,10,100,0 => 1101000
> > (97,8,9) sorting gives: 9,97,8 => 9978
> >
> > correct me if i'm wrong.
> >
> > Shubham
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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