Skip to content

Commit

Permalink
Time: 31 ms (92.14%), Space: 16.2 MB (47.38%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Oct 29, 2023
1 parent f09e2c1 commit 6b96a35
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 1894-merge-strings-alternately/1894-merge-strings-alternately.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6b96a35

Please sign in to comment.