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
Okay, how about this algorithm , which uses compare function to check previous number and the number in the next index.For the sake of simplicity, i have used strings instead of integers.Though, the algorithm well explains what it is doing.
#include
#include
#include
using namespace std;
int main(){
bool arranged=false;
string arr[]={"98","12","56","9"};
for(int i=0;i<4;i++)
cout< 0 ) {
swap(arr[i],arr[i-1]);
arranged = false;
}
previous = arr[i];
}
}
for(int i=0;i<4;i++)
cout<