Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- opening_brackets_count = 0
- closing_brackets_count = 0
- is_balanced = False
- for i in range(0, n):
- text = input()
- if text == "(":
- opening_brackets_count += 1
- elif text == ")":
- closing_brackets_count += 1
- if closing_brackets_count == opening_brackets_count:
- is_balanced = True
- print(f"BALANCED")
- else:
- print(f"UNBALANCED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement