@Yasir: I think the following will work. Counterexamples welcome. Find the number of digits in each of the integers, and find the max of that number, say m.
Fill a second array as follows: If the ith integer has m digits, copy it into the second array. If the ith number has less than m digits, concatenate duplicates of the last digit of the integer to the right end to expand it to m digits. Examples: m = 3, 7 goes to 777; 82 goes to 822; 29 goes to 299; 0 goes to 000. Sort the second array into descending order and carry the first array along (apply the same permutations to the first array as you do to the second). Concatenate the integers in the first array to get the result. Dave On Aug 12, 7:34 am, Yasir Imteyaz <yasir....@gmail.com> wrote: > An array of integers is given and you have to find the largest possible > integer by concatenating all elements: > > example: > array: 87 36 52 > answer: 875236 > > array: 87 9 52 > answer: 98752 -- 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.