Skip to content

Commit b75d81e

Browse files
author
Partho Biswas
committed
no message
1 parent df13c8a commit b75d81e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

algoexpert.io/python/Balanced_Bracket.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
# O(n) time | O(n space)
5-
def balanced_brackets(string):
5+
def balancedBrackets(string):
66
opening_brackets = "([{"
77
closing_brackets = ")]}"
88
matching_brackets = {")": "(", "]": "[", "}": "{"}
@@ -13,10 +13,9 @@ def balanced_brackets(string):
1313
elif char in closing_brackets:
1414
if len(stack) == 0:
1515
return False
16-
# stack[-1] denotes the last value of stack
1716
if stack[-1] == matching_brackets[char]:
1817
stack.pop()
1918
else:
2019
return False
21-
return len(string) == 0
20+
return len(stack) == 0
2221

0 commit comments

Comments
 (0)