We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef5fd44 commit 7aca5c4Copy full SHA for 7aca5c4
Strings/Valid Paranthesis
@@ -0,0 +1,25 @@
1
+//Leetcode
2
+
3
+class Solution {
4
+public:
5
+ bool isValid(string s) {
6
+ stack<char>st;
7
+ for(int i = 0;i<s.size();i++){
8
+ if(s[i]=='(' || s[i]=='{' || s[i]=='['){
9
+ st.push(s[i]);
10
+ }
11
+ else{
12
+ if(!st.empty() &&((s[i]==')' && st.top()=='(')||(s[i]==']' && st.top()=='[')||(s[i]=='}' && st.top()=='{'))){
13
+ st.pop();
14
15
16
+ return false;
17
18
19
20
+ if(!st.empty()){
21
22
23
+ else return true;
24
25
+};
0 commit comments