leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2264.cpp (355B)


      1 class Solution {
      2   public:
      3     string largestGoodInteger(const string &num) const {
      4         int res = -1;
      5         for (int i = 0; i < num.size() - 2; i++) {
      6             if (num[i] == num[i + 1] && num[i] == num[i + 2]) {
      7                 res = max(res, num[i] & 0x0F);
      8             }
      9         }
     10         return res == -1 ? "" : string(3, '0' + res);
     11     }
     12 };