class Solution {
public String mergeAlternately(String word1, String word2) {
String result = "";
int end = word1.length() > word2.length() ? word1.length() : word2.length();
for (int i = 0; i < end; i++) {
if (i < word1.length() && i < word2.length()) {
result += word1.charAt(i);
result += word2.charAt(i);
continue;
}
if (i < word1.length()) {
String record = word1.substring(i, word1.length());
result += record;
break;
}
if (i < word2.length()) {
String record = word2.substring(i, word2.length());
result += record;
break;
}
}
return result;
}
}
10-23
921
