Merge Strings Alternately
Build a string by taking one letter from word1, then one from word2, then the next from word1, and so on. When one string runs out, add all remaining letters of the other string to the end.
Example 1
word1 "abc"
word2 "pqr"
returns "apbqcr"
Alternating gives apbqcr.
Example 2
word1 "ab"
word2 "pqrs"
returns "apbqrs"
apbq then the rest rs.
Constraints
0 <= len(word1), len(word2) <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.