Created
April 18, 2020 08:53
-
-
Save ABHIINAV12/01971eeb1cd0f3fb393725bb8efcdc01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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