Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def validParentheses? str
a = []
str.each_char do |x|
if x == '('
a.push x
elsif x == ')'
return false if a.pop == nil
end
end
a.empty?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment