leetcode

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

1750.cpp (358B)


      1 class Solution {
      2   public:
      3     int minimumLength(const string &s) const {
      4         int i = 0, j = size(s) - 1;
      5         while (i < j && s[i] == s[j]) {
      6             const int goal = s[i];
      7             while (i <= j && s[i] == goal)
      8                 i++;
      9             while (i < j && s[j] == goal)
     10                 j--;
     11         }
     12 
     13         return j - i + 1;
     14     }
     15 };