Description


Submission
class Solution { public: string largestMerge(string word1, string word2) { int i = 0, j = 0; string ret = ""; for(; i < word1.size() && j < word2.size() ; ) { if(word1.substr(i, word1.size() - i) > word2.substr(j, word2.size() - j)) { ret += word1[i++]; } else { ret += word2[j++]; } } if(i != word1.size()) { ret += word1.substr(i, word1.size() - i); } if(j != word2.size()) { ret += word2.substr(j, word2.size() - j); } return ret; } };
