nikunjsoni

1003

Mar 26th, 2021
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. public:
  3.     bool isValid(string s) {
  4.         int i, j;
  5.         for(i=0, j=0; j<s.length(); i++, j++){
  6.             s[i] = s[j];
  7.             if(i >= 2 && s[i] == 'c' && s[i-1] == 'b' && s[i-2] == 'a')
  8.                 i -= 3;
  9.         }
  10.         return i ? false : true;
  11.     }
  12. };
RAW Paste Data