day1
C++ 代码
class Solution {
public:
string largestGoodInteger(string num) {
string res; //默认res = "";
for (int i = 0; i < num.size() - 2; i ++ ) //防止越界
{
if (num[i] == num[i + 1] && num[i + 1] == num[i + 2])
{
res = max(res, num.substr(i, 3)); //max函数也可以直接比较string对象
}
}
return res;
}
};