Skip to content

Commit aa6b360

Browse files
authored
Merge pull request #2678 from SaiTeja-002/main
Create: 1768-merge-strings-alternately.cpp
2 parents 5c2a2cc + c4f950e commit aa6b360

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)