Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution{
- public:
- // The main function that returns the arrangement with the largest value as
- // string.
- // The function accepts a vector of strings
- static bool compareStrings(const string &a, const string &b) {
- return a + b > b + a;
- }
- string printLargest(vector<string> &arr) {
- sort(arr.begin(), arr.end(), compareStrings);
- string result = "";
- for (const string &s : arr) {
- result += s;
- }
- return result;
- }
- };
- https://practice.geeksforgeeks.org/problems/largest-number-formed-from-an-array1117/
Advertisement
Add Comment
Please, Sign In to add comment