diff --git a/1894-merge-strings-alternately/1894-merge-strings-alternately.py b/1894-merge-strings-alternately/1894-merge-strings-alternately.py new file mode 100644 index 0000000..5b6ece6 --- /dev/null +++ b/1894-merge-strings-alternately/1894-merge-strings-alternately.py @@ -0,0 +1,12 @@ +class Solution: + def mergeAlternately(self, word1: str, word2: str) -> str: + res = "" + i = 0 + while i < len(word1) or i < len(word2): + if i < len(word1): + res += word1[i] + if i < len(word2): + res += word2[i] + i += 1 + + return res