Skip to content

Commit

Permalink
stack
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueimaginate committed Mar 8, 2021
1 parent 5faec26 commit db675d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Coding Test/856.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution(object):
def scoreOfParentheses(self, S):
stack = [0] #The score of the current frame

for x in S:
if x == '(':
stack.append(0)
else:
v = stack.pop()
stack[-1] += max(2 * v, 1)

return stack.pop()
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
2. Linked List
> 234, 21, 206, 2, 24, 328, 92
3. Stack, Queue
> 20, 739, 225, 622, 316
> 책: 20, 739, 225, 622, 316
> 856
4. Deque, Priority Queue
5. Hash Table
> 771
Expand Down

0 comments on commit db675d0

Please sign in to comment.