We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This particular c++ solution passed all test case.Nothing much to learn except for the comparison to be made inside the function.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;// Use of comparator//comparing function only sorts if string size is equal and keeps the larger integgers at last.boolmyfunction(stringi,stringj){intn=i.length();intm=j.length();if(n==m)return(i<j);returnn<m;}intmain(){intn;cin>>n;vector<string>arr(n);for(inti=0;i<n;i++)cin>>arr[i];sort(arr.begin(),arr.end(),myfunction);for(inti=0;i<n;i++)cout<<arr[i]<<endl;return0;}
Big Sorting
You are viewing a single comment's thread. Return to all comments →
This particular c++ solution passed all test case.Nothing much to learn except for the comparison to be made inside the function.