Merge Strings Alternately

Easy · Arrays & Strings · about 5 minutes

Asked at Google, Microsoft, Amazon, Meta, Bloomberg.

Interleave two strings letter by letter, taking from word1 first, then word2, then word1 again, and so on. Once one string runs out, tack the rest of the other onto the end. Return the result.

Related guides