Skip to content

Commit 8e06c7a

Browse files
authored
Create 2937-make-three-strings-equal.js
1 parent 0f0c811 commit 8e06c7a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2937-make-three-strings-equal.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @param {string} s1
3+
* @param {string} s2
4+
* @param {string} s3
5+
* @return {number}
6+
*/
7+
var findMinimumOperations = function(s1, s2, s3) {
8+
let a = s1.length
9+
let b = s2.length
10+
let c = s3.length
11+
12+
let min = Math.min(a, Math.min(b, c))
13+
let i = 0
14+
for (; i < min; i++) {
15+
let c1 = s1.charAt(i)
16+
let c2 = s2.charAt(i)
17+
let c3 = s3.charAt(i)
18+
if (c1 !== c2 || c2 !== c3) {
19+
break
20+
}
21+
}
22+
if (i === 0) return -1
23+
let ans = 0
24+
ans = a - i + b - i + c - i
25+
return ans
26+
};

0 commit comments

Comments
 (0)