File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -31,23 +31,23 @@ class Solution {
31
31
string minRemoveToMakeValid (string s) {
32
32
stack<pair<char ,int >> st;
33
33
34
- for (int i= 0 ;i< s.size ();i++){
35
- if (s[i]== ' (' ){
36
- st.push (make_pair (s[i],i));
37
- }else if (s[i]== ' )' ){
38
- if (!st.empty () and st.top ().first == ' (' ){
34
+ for (int i = 0 ; i < s.size (); i++) {
35
+ if (s[i] == ' (' ) {
36
+ st.push (make_pair (s[i], i));
37
+ } else if (s[i] == ' )' ) {
38
+ if (!st.empty () and st.top ().first == ' (' ) {
39
39
st.pop ();
40
- }else {
41
- st.push (make_pair (' )' ,i));
40
+ } else {
41
+ st.push (make_pair (' )' , i));
42
42
}
43
43
}
44
44
}
45
45
46
- while (!st.empty ()){
47
- s.erase (s.begin ()+ st.top ().second );
46
+ while (!st.empty ()) {
47
+ s.erase (s.begin () + st.top ().second );
48
48
st.pop ();
49
49
}
50
50
51
51
return s;
52
52
}
53
- };
53
+ };
You can’t perform that action at this time.
0 commit comments