class Solution {
public String mergeAlternately(String word1, String word2) {
int len1 = word1.length(), len2 = word2.length();
int index = 0;
char[] result = new char[len1 + len2];
for(int i = 0; i < len1 || i < len2; i++){
if(i < len1) result[index++] = word1.charAt(i);
if(i < len2) result[index++] = word2.charAt(i);
}
return new String(result);
}
}