Description
![](https://kickstart.best/wp-content/uploads/2021/08/Screen-Shot-2021-08-18-at-12.06.40-AM.png)
Submission
class Solution { public: bool checkValidString(string s) { int countMin = 0, countMax = 0; for(char ch: s) { if(ch == '(') { ++countMin; ++countMax; } else if(ch == ')') { --countMin; --countMax; } else { --countMin; ++countMax; } if(countMax < 0) { return false; } if(countMin < 0) { countMin = 0; // convert to empty string } } return countMin == 0; } };
![](https://kickstart.best/wp-content/uploads/2021/08/Screen-Shot-2021-08-18-at-12.08.09-AM.png)