You are given two strings
word1
andword2
. Merge the strings by adding letters in alternating order, starting withword1
. If a string is longer than the other, append the additional letters onto the end of the merged string.
Return the merged string.
Constraints:
1 <= word1.length, word2.length <= 100
word1
andword2
consist of lowercase English letters.
給你兩個字串
word1
和word2
。從word1
開始,透過交替的順序將字串們合併。如果一個字串比另一個長,將多的字母加到合併字串的尾端。
回傳合併後的字串。
限制:
1 <= word1.length, word2.length <= 100
word1
和word2
只包含小寫英文字母。
word1
或 word2
現有空間操作word1
和 word2
的字母放進去,直到其中一個放完了
word1
word1.size() + word2.size()
的 char* 空間即可LeetCode
C++