Error:
- s.erase() will erase the char in s then return!!! If you want to get the s.erase and s, it should use another string to store s then erase the char
- Do not know how to do: when an parenthese is valid will have:
- If i not in the end, left >= right
- If i meet the end, left == right
In other word, any string do not has this case is invalid, so that we can use a variable to check it.
Then, we first delete the first parenthese when meet duplicate
update:
pattern:
1. valid current string is valid or not. By using rule: if not meet the end, '('s number is greater than ‘)’; if meet the end, ‘(’ is equal to ‘)’
2. check original string mistake parenthesis. By using the same rule above.
3. use dfs the traverse the ‘(’ and ‘)’.