Created
April 15, 2018 11:33
-
-
Save seanballais/a1163dcd4d64d2e45a52b54f8e01b0f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pair_balance(parentheses): | |
missing_pairs = 0 | |
for parenthesis in parentheses: | |
if parenthesis == '(': | |
missing_pairs += 1 | |
elif parenthesis == ')': | |
if missing_pairs == 0: | |
return False | |
missing_pairs -= 1 | |
return True if missing_pairs == 0 else False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment