Description:

Solution:

In pariHash, we set close parentheses as a key, and open parentheses as a value.
If the c is open parentheses, we append on stack.
If the c is closing parentheses, we search the last value of stack "stack[-1]" and compare it with its key.
We can pop the stack.
If the stack is empty at the end of the solution, we can return True.
Time Complexity: O(n)
Space Complexity: O(n)
'LeetCode ๐๏ธ > String' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| 5. Longest Palindromic Substring (0) | 2023.06.20 |
|---|---|
| 125. Valid Palindrome (0) | 2023.06.19 |
| 49. Group Anagrams (0) | 2023.06.17 |
| 242. Valid Anagram (0) | 2023.06.16 |
| 76. Minimum Window Substring (0) | 2023.06.15 |