Skip to content

Commit

Permalink
Added cpp program
Browse files Browse the repository at this point in the history
  • Loading branch information
1999code committed Oct 26, 2022
1 parent 4c8a600 commit dc54a6f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

50 changes: 50 additions & 0 deletions leetcode/Valid Parenthesis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class Solution {
public:
bool isValid(string expression) {
stack<char>s;
for(int i=0;i<expression.length();i++){
char ch = expression[i];
//opening parantheses push
if(ch=='(' || ch=='{' || ch=='[')
{
s.push(ch);

}
//for close parantheses check on top and pop
else
{
if(!s.empty()) {
char top=s.top();


if( ch==')' && top=='('
||
ch=='}' && top=='{'
||
ch==']' && top=='[')
{
s.pop();
}
else
{
return false;
}
}
else {
return false;
}


}



}
if(s.empty())
return true;


else
return false;
}
};
18 changes: 18 additions & 0 deletions leetcode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
""
]
}
],
"version": 4
}

0 comments on commit dc54a6f

Please sign in to comment.