SHARE
TWEET

Untitled

a guest Oct 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool comparison(int a, int b){
  2.     string sa=to_string(a), sb=to_string(b);
  3.     return sa+sb>sb+sa;
  4. }
  5.  
  6. string Solution::largestNumber(const vector<int> &A) {
  7.     vector<int> a;
  8.     for(int i=0; i<A.size(); i++) a.push_back(A[i]);
  9.     sort(a.begin(), a.end(), comparison);
  10.     string s="";
  11.     for(int i=0; i<A.size(); i++) s=s+to_string(a[i]);
  12.     if(s[0]=='0') return "0";
  13.     else return s;
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top