This commit is contained in:
Volodymyr Baliasnikov 2026-10-13 14:39:27 +02:00
parent ec396b2a1f
commit a22e29b09a

12
u6/matching_brackets.py Normal file
View File

@ -0,0 +1,12 @@
def is_paired(input_string):
zatvorky = {'(': ')', '[': ']', '{': '}'}
stack = []
for char in input_string:
if char in zatvorky:
stack.append(char)
elif char in zatvorky.values():
if not stack or zatvorky[stack.pop()] != char:
return False
return not stack