Form biggest no. in array


hey can you please explain me the error and correct the code where it is wrong

hi dhruv
your compare function is correct.
there are several mistakes in your code.
you are comparing strings so you need to change the integer array into strings and apply sort function on the strings array.
int n;
cin>>n;
int arr[n];
vectorvec1;
for(int i=0;i<n;i++)
{
cin>>arr[i];
string str;
str=to_string(arr[i]);
vec1.push_back(str);
}

thanks a lot problem done

but can you please tell why did we use vector and not solve directly throug arrays

things are made easier through vectors.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.