Problem
You get two strings, word1 and word2. Merge them into one new string. Take one letter from word1, then one letter from word2, and continue in this order.
When one string has no more letters, add all the remaining letters of the other string to the end. Return the merged string.
Example 1
- Input:
- word1 = "cat", word2 = "dog"
- Output:
- "cdaotg"
- Explanation:
- The merged string alternates the letters of
word1andword2:c,d,a,o,t,g.
Example 2
- Input:
- word1 = "go", word2 = "tiger"
- Output:
- "gtoiger"
- Explanation:
- After
g,t,oandi,word1has no more letters. The merged string ends withgerfromword2.
Example 3
- Input:
- word1 = "hello", word2 = "ok"
- Output:
- "hoekllo"
- Explanation:
word2has only two letters. The merged string ends withllofromword1.
Constraints
- 1 <= word1.length, word2.length <= 100
- word1 and word2 have only lowercase English letters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Largest Merge Of Two Strings
Coding
- Accounts Merge
Coding · Array · Breadth-First Search · Depth-First Search
- Add Strings
Coding
- Add two decimal strings e.g. '123.45' + '236.7'
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1768. Merge Strings Alternately
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source