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
Here is Python 3 solution where a
is an array and n
is the total number of element
def check(p,q):
p=str(p)
q=str(q)
d=max(p+q,q+p)
if d==p+q:
return int(p),int(q)
else:
return int(q),int(p)
def find(a,n):
for i in range(n):
for j in range(n-1):
c,d=check(a[j],a[j+1])
a[j]=c
a[j+1]=d
print(*a,sep="")