The critical thing here is how to define your comparator function to be used for sorting. Sorting using the normal comparator function will return the following: 31 33 55 312
Using insertion sort O(n^2) such that the resultant concatenation is smallest, should do it. The steps for [55,31,312,33] would be: 55 31 55 312 31 55 312 31 33 55 which gives the correct result :) Defining the comparator function on these lines should do it in O(nlogn) as well. On Thu, Aug 19, 2010 at 5:02 PM, Shiv ... <shivsinha2...@gmail.com> wrote: > An interesting idea would be treat the inputs as strings and sort them. > > > > > > On Thu, Aug 19, 2010 at 4:01 AM, amit <amitjaspal...@gmail.com> wrote: > >> Given an array of numbers. Calculate a permutation when the >> concatenate number is smallest. For instance, [55,31,312,33] is >> 312313355 >> >> -- >> 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<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > Please access the attached hyperlink for an important electronic communications disclaimer: http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php -- 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.