Largest 3-Same-Digit Number in String LeetCode solution in C++

1
class Solution {
2
public:
3
string largestGoodInteger(string num) {
4
for (int i = '9'; i >= '0'; i--) {
5
string s;
6
s += i;
7
s += i;
8
s += i;
9
// S will be 999 or 888 or 777 or 666 or 555 or 444 or 333 or 222 or 111
10
// or 000
11
if (num.find(s) != string::npos) return s;
12
}
13
return "";
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0