Largest 3-Same-Digit Number in String LeetCode solution in JavaScript

1
var largestGoodInteger = function (num) {
2
let maxGoodInt = "";
3
for (let i = 0; i <= num.length - 3; i++) {
4
if (num[i] === num[i + 1] && num[i + 1] === num[i + 2]) {
5
if (num[i] >= maxGoodInt) {
6
maxGoodInt = num[i];
7
}
8
}
9
}
10
return maxGoodInt + maxGoodInt + maxGoodInt;
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0