leetcode

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

1544.cpp (330B)


      1 class Solution {
      2   public:
      3     string makeGood(string s) {
      4         int i = 0;
      5         while (i < s.size())
      6             if (s[i] != s[i + 1] && toupper(s[i]) == toupper(s[i + 1])) {
      7                 s.erase(i, 2);
      8                 i = max(0, i - 1);
      9             } else {
     10                 i++;
     11             }
     12         return s;
     13     }
     14 };