https://leetcode.com/problems/largest-number



Runtime: 4 ms, faster than 96.77% of C++ online submissions for Largest Number.
Memory Usage: 11.5 MB, less than 39.24% of C++ online submissions for Largest Number.




```cpp
#include <bits/stdc++.h>

using namespace std;

void ltrim(std::string &s) {
  while(s.size() && *(s.begin()) == '0') {
      s.erase(s.begin());
  }
}

bool myCompareFunction(string a, string b)
{
  if (stoll(a+b) > stoll(b+a) ) {
    return true;
  } else {
    return false;
  }
}

class Solution {
public:
    string largestNumber(vector<int>& nums) {
      // 7:18
      vector<string> num_string_list;
      for (auto num : nums) {
        num_string_list.push_back(to_string(num));
      }
      sort(num_string_list.begin(), num_string_list.end(), myCompareFunction);

      string result;
      for (auto num : num_string_list) {
        result += num;
      }
        

      ltrim(result);

      cout << result;
        
      if (result == "") {
        return "0";
      } else {
        return result;
      }
      //7:25
      // debug until 7:37
    }
};
```