Practice Merge Strings Alternately
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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.
Source: Merge Strings Alternately on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
word1 = "abc", word2 = "pqr"
Output
"apbqcr"
# Example 2
Input
word1 = "ab", word2 = "pqrs"
Output
"apbqrs"
# Example 3
Input
word1 = "abcd", word2 = "pq"
Output
"apbqcd"
Constraints
1 <= word1.length, word2.length <= 100
word1 and word2 consist of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Merge Strings Alternately.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.