Say you have an array of positive integers, manipulate them so that the concatenation of the integers of the resultant array is the largest number possible. Ex: {9,1,95,17,5}, r
I guess it has already been solved. Here are few lines of code in Python using the logic already discussed in few of the answers:
>>li = [9,1,95,17,5] >>li.sort(cmp=lambda a,b: cmp(int(str(a)+str(b)), int(str(b) + str(a))), reverse=True) >>output = "" >>for i in li: output += str(i) >>print output