-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2264.cpp
More file actions
38 lines (36 loc) · 757 Bytes
/
Copy path2264.cpp
File metadata and controls
38 lines (36 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <string>
using namespace std;
class Solution
{
public:
string largestGoodInteger(string num)
{
if (num.size() < 3)
{
return "";
}
string a = "";
while (num.size() > 3)
{
string temp = string(num.begin(), num.begin() + 3);
if (temp[0] != temp[1] || temp[0] != temp[2] || temp[1] != temp[2])
{
continue; // return "";
}
else
{
if (temp > a)
{
a = temp;
}
// return temp;
}
}
return a;
}
};
int main()
{
Solution s;
string a = s.largestGoodInteger("000111333222555");
}