@Bhavesh: Counter case for you: array = {68, 6867} u change this array to: {6866, 6867} then u sort them to get 6867, 6866 and then give the ans as: 686768. While the correct ans is: 686867
The problem in ur algo is in appending the first digit at the end of each number. For a correct algo, not just the first digit but the complete number should be appended. Hence, to get correct result, you should change the array to : {6868, 6867}. Hope this makes things clear for you. Cheers Nikhil Jindal http://sites.google.com/site/aboutnikhiljindal/ On Mon, May 30, 2011 at 3:28 PM, Bhavesh agrawal <agr.bhav...@gmail.com>wrote: > solution may be > > > array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all > exceptions ) > > then ,change this array like 33333 , 21222, 99999, 93999, 17111, 17811, > 11111 , 10111 ( make each number of 5 digit with rest digits same as Ist > digit ) > then sort this array > > 99999, 93999,33333 21222, 17811,17111, 11111, 10111 > and make it with actual numbers > > 9,93,3,21,178,17,1,101 = 993321178171101 > > plz let me know if any case left... > > -- > 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.