第一题

class Solution:
    def mergeAlternately(self, word1: str, word2: str) -> str:
        #计算两个字符串长度,从i = 0开始遍历,每次循环:
        #如果i小于word1的长度,把word1[i]加到答案末尾
        #如果i小于word2的长度,把word2[i]加到答案末尾
        #循环直到i达到word1的长度和word2长度的最大值。
        ans = []
        i,n,m = 0,len(word1),len(word2)
        while i < n or i < m:
            if i<n:
                ans.append(word1[i])
            if i < m:
                ans.append(word2[i])
            i += 1
        return "".join(ans)
      # 时间复杂度:O(n+m),其中 n 是 word1的长度,m 是 word2的长度。
       #空间复杂度:O(n+m) 或 O(1)。C++ 不计入返回值的空间。



















