Search⌘ K
AI Features

Solution: Merge Strings Alternately

Solution: Merge Strings Alternately asks you to combine two strings by taking characters in turn, starting with the first string, then append any leftover characters from the longer string.

Statement

Given two strings word1 and word2, merge them by interleaving their characters in alternating order, beginning with the first character of word1. If one string is longer than the other, append the remaining characters of the longer string to the end of the merged result.

Return the resulting merged string.

Constraints:

  • 1≤1 \leq word1.length, word2.length ≤100\leq 100

  • word1 and word2 consist of lowercase English letters. ...