Skip to content

Instantly share code, notes, and snippets.

@ABHIINAV12
Created April 18, 2020 08:53
Show Gist options
  • Save ABHIINAV12/01971eeb1cd0f3fb393725bb8efcdc01 to your computer and use it in GitHub Desktop.
Save ABHIINAV12/01971eeb1cd0f3fb393725bb8efcdc01 to your computer and use it in GitHub Desktop.
class Solution {
public:
bool checkValidString(string s) {
int l=0,h=0;
for(char it : s){
l+= it=='(' ? 1: -1;
h+= it!= ')' ? 1: -1;
if(h<0) break;
l=max(l,0);
}
return l==0;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment