Skip to content

Commit

Permalink
Create 921. Minimum Add to Make Parentheses Valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Oct 9, 2024
1 parent eff2af5 commit 44abfd5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 921. Minimum Add to Make Parentheses Valid
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:

int minAddToMakeValid(string s) {
stack<char> stac;
for(char c : s)
{
if(!stac.empty() && stac.top()=='(' && c==')')stac.pop();
else stac.push(c);
}
return stac.size();
}
};

0 comments on commit 44abfd5

Please sign in to comment.