题目:
代码(首刷看题解 DAY1):
class Solution {
public:
string mergeAlternately(string word1, string word2) {
int len1=word1.size();
int len2=word2.size();
string res;
int i=0,j=0;
while(i<len1||j<len2){
if(i<len1){
res+=word1[i];
++i;
}
if(j<len2){
res+=word2[j];
++j;
}
}
return res;
}
};