We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5d0eaee commit 726f53cCopy full SHA for 726f53c
1754-largest-merge-of-two-strings.js
@@ -1,3 +1,40 @@
1
+/**
2
+ * @param {string} word1
3
+ * @param {string} word2
4
+ * @return {string}
5
+ */
6
+var largestMerge = function(word1, word2) {
7
+ let merge = "";
8
+
9
+ while(word1.length && word2.length) {
10
+ if (word1[0] > word2[0]) {
11
+ merge += word1[0];
12
+ word1 = word1.slice(1);
13
+ } else if (word1[0] < word2[0]) {
14
+ merge += word2[0];
15
+ word2 = word2.slice(1);
16
+ } else {
17
+ if (word1 > word2) {
18
19
20
21
22
23
+ }
24
25
26
27
+ if (word1.length) {
28
+ merge += word1;
29
+ } else if (word2.length) {
30
+ merge += word2;
31
32
33
+ return merge;
34
+};
35
36
+// another
37
38
/**
39
* @param {string} word1
40
* @param {string} word2
0 commit comments