03(March) Largest Number formed from an Array
03. Largest Number formed from an Array
My Approach
Time and Auxiliary Space Complexity
Code (C++)
class Solution {
public:
static bool comp(string a, string b){
return a + b > b + a;
}
string printLargest(int n, vector<string> &arr) {
sort(arr.begin(), arr.end(), comp);
string ans;
for(string i : arr)
ans += i;
return ans;
}
};Contribution and Support
📍Visitor Count
Last updated