We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0dcab9 commit 59df090Copy full SHA for 59df090
LeetCode/Merge_String_Alternately.java
@@ -0,0 +1,26 @@
1
+class Solution {
2
+ public String mergeAlternately(String word1, String word2) {
3
+ String s = "";
4
+ int m = word2.length();
5
+ int n= word1.length();
6
+ int l = m>n?n:m;
7
+ int i=0;
8
+ for(;i<l;i++){
9
+ char ch = word1.charAt(i);
10
+ s=s+ch;
11
+ m--;
12
+ char ch2 = word2.charAt(i);
13
+ s=s+ch2;
14
+ n--;
15
+ }
16
+ if(m>0){
17
+ s=s+word2.substring(i);
18
+ }else{
19
+ s=s+word1.substring(i);
20
21
+ return s;
22
23
+
24
25
+}
26
+Footer
0 commit comments