u6
This commit is contained in:
parent
494c226d92
commit
1d83cc3f68
16
u6/matching_brackets.py
Normal file
16
u6/matching_brackets.py
Normal file
@ -0,0 +1,16 @@
|
||||
PARY = {")": "(", "]": "[", "}": "{"}
|
||||
OTVARACIE = set(PARY.values())
|
||||
|
||||
|
||||
def is_paired(input_string):
|
||||
zasobnik = []
|
||||
|
||||
for znak in input_string:
|
||||
if znak in OTVARACIE:
|
||||
zasobnik.append(znak)
|
||||
elif znak in PARY:
|
||||
if not zasobnik or zasobnik.pop() != PARY[znak]:
|
||||
return False
|
||||
|
||||
return not zasobnik
|
||||
|
||||
Loading…
Reference in New Issue
Block a user