Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Merge Strings Alternately - Leetcode 1768/samad's_solution
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution(object):
def mergeAlternately(self, word1, word2):
"""
:type word1: str
:type word2: str
:rtype: str
"""
ans = ""
j = min(len(word2), len(word1))

for i in range(j):
ans += word1[i]
ans += word2[i]

return ans + word1[j:] + word2[j:]