Merge Strings Alternately
EasyTwo Pointers
Decode it first. Clues, constraints, pattern and plan before any code.Given two strings word1 and word2, build a new string by taking letters alternately, starting with word1: first letter of word1, first letter of word2, second of word1, and so on. If one string is longer, append the rest of it to the end.
word1 = "abc", word2 = "pqr" → "apbqcr"
word1 = "ab", word2 = "pqrs" → "apbqrs"
word1 = "abcd", word2 = "pq" → "apbqcd"Constraints
1 <= word1.length, word2.length <= 100- Both strings contain only lowercase English letters.