leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1750.cpp (358B)
0 class Solution {
1 public:
2 int minimumLength(const string &s) const {
3 int i = 0, j = size(s) - 1;
4 while (i < j && s[i] == s[j]) {
5 const int goal = s[i];
6 while (i <= j && s[i] == goal)
7 i++;
8 while (i < j && s[j] == goal)
9 j--;
10 }
12 return j - i + 1;
13 }
14 };