Loading the journal
Loading the journal
Two Pointers (Zip)
5 in the last 6 months
Community-reported company tags from leetcode-company-wise-problems (updated 2026-10-08). Bar shows how often each company asks it.
Problem
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.
Return the merged string.
Input: word1 = "abc", word2 = "pqr"
Output: "apbqcr"
Input: word1 = "ab", word2 = "pqrs"
Output: "apbqrs"
Input: word1 = "abcd", word2 = "pq"
Output: "apbqcd"
1 ≤ word1.length, word2.length ≤ 100
word1 and word2 consist of lowercase English letters
word1, then one from word2, repeatReading the solution first feels like progress, but it makes the next similar problem — and the interview version — much harder, because you skipped the part where you figure it out. Give it an honest 20–30 minutes. Stuck? Re-read the pattern, watch the concept video, or try the brute force first.
Hidden: approach · solution code