Skip to content

Commit c4f950e

Browse files
authored
Create: 1768-merge-strings-alternately.cpp
File(s) Modified: 1768-merge-strings-alternately.cpp Language(s) Used: cpp Submission URL: https://leetcode.com/problems/merge-strings-alternately/submissions/987141062/
1 parent ee29457 commit c4f950e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: cpp/1768-merge-strings-alternately.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
string mergeAlternately(string word1, string word2)
4+
{
5+
int i=0;
6+
string final="";
7+
8+
while(i < word1.size() && i < word2.size())
9+
final = final + word1[i] + word2[i++];
10+
11+
while(i < word1.size())
12+
final += word1[i++];
13+
while(i < word2.size())
14+
final += word2[i++];
15+
16+
return final;
17+
}
18+
};

0 commit comments

Comments
 (0)