1768. Merge Strings Alternately
给你两个字串s1和s2,合并两个字串并使其交错。
Example:
Input: word1 = "abc", word2 = "pqr"
Output: "apbqcr"
Explanation: The merged string will be merged as so:
word1: a b c
word2: p q r
merged: a p b q c r
Example 2:
Input: word1 = "ab", word2 = "pqrs"
Output: "apbqrs"
Explanation: Notice that as word2 is longer, "rs" is appended to the end.
word1: a b
word2: p q r s
merged: a p b q r s
思路:
1.把两个字串按照顺序一个一个放到阵列,直到两个都放完为止。
Java Code: