Merge Strings Alternately LeetCode solution in Python

1
# Runtime: 7 ms (Top 98.2%) | Memory: 13.31 MB (Top 45.5%)
2

3

4
class Solution(object):
5
def mergeAlternately(self, word1, word2):
6
i = 0
7
j = 0
8
st = []
9
while i < len(word1) and j < len(word2):
10
st.append(word1[i])
11
st.append(word2[j])
12
i += 1
13
j += 1
14
while j < len(word2):
15
st.append(word2[j])
16
j += 1
17
while i < len(word1):
18
st.append(word1[i])
19
i += 1
20
return "".join(st)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0