Stack (My Solution)
1 | class Solution { |
Remarks:
- java character stack:
Stack<Character> lefts = new Stack<>();but not<char> - Return
lefts.isEmpty();, if some parentheses was not closed
Formatted
1 | class Solution { |
Remarks:
- Use more time than the simple one: HashMap takes time to initialize
- Use HashMap to make code cleaner