We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8cd7f25 commit 0585544Copy full SHA for 0585544
largest_merge_of_two_strings.cpp
@@ -0,0 +1,24 @@
1
+class Solution {
2
+public:
3
+ string largestMerge(string word1, string word2) {
4
+ string ans="";
5
+ while(!word1.empty() || !word2.empty()) {
6
+ if(word1[0]>word2[0]) {
7
+ ans+=word1[0];
8
+ word1.erase(word1.begin());
9
+ }else if(word1[0]<word2[0]) {
10
+ ans+=word2[0];
11
+ word2.erase(word2.begin());
12
+ }else {
13
+ if(word1<word2) {
14
15
16
17
18
19
+ }
20
21
22
+ return ans;
23
24
+};
0 commit comments