You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.

Return the merged string.

&nbsp;
Example 1:

Input: word1 = "abc", word2 = "pqr"
Output: "apbqcr"
Explanation:&nbsp;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:&nbsp;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


Example 3:

Input: word1 = "abcd", word2 = "pq"
Output: "apbqcd"
Explanation:&nbsp;Notice that as word1 is longer, "cd" is appended to the end.
word1:  a   b   c   d
word2:    p   q 
merged: a p b q c   d


&nbsp;
Constraints:


	1 &lt;= word1.length, word2.length &lt;= 100
	word1 and word2 consist of lowercase English letters.

class Solution(object):
    def mergeAlternately(self, word1, word2):
        i=0
        j=0
        st=[]
        while i<len(word1) and j<len(word2):
            st.append(word1[i])
            st.append(word2[j])
            i+=1
            j+=1
        while j<len(word2):
            st.append(word2[j])
            j+=1
        while i<len(word1):
            st.append(word1[i])
            i+=1
        return "".join(st)
class Solution {
    public String mergeAlternately(String word1, String word2) {
        StringBuilder sb = new StringBuilder();
        int lenmax = Math.max(word1.length(),word2.length());
        for(int i=0;i<=lenmax-1;i++)
        {
            if(i<word1.length()) sb.append(word1.charAt(i));
            if(i<word2.length()) sb.append(word2.charAt(i));
        }
        return sb.toString();
    }
}
class Solution {
public:
    string mergeAlternately(string word1, string word2) {
        string final="";
        int p=word1.size();
        int q=word2.size();
        int n=max(p,q);
        for(int i=0;i<n;i++){
            if(p){
                final=final+word1[i];
                p--;
            }
            if(q){
                final=final+word2[i];
                q--;
            }
        }
        return final;
    }
};
/**
 * @param {string} word1
 * @param {string} word2
 * @return {string}
 */
var mergeAlternately = function(word1, word2) {
    let length = Math.max(word1.length, word2.length), s = '';
    for(let i = 0; i < length; i++){
        s+= word1[i] || '';
        s+= word2[i] || '';
    }
    return s;
};
Merge Strings Alternately