Skip to content

Instantly share code, notes, and snippets.

@oleglukashev
Created April 26, 2015 14:54
Show Gist options
  • Save oleglukashev/12b3d0f2596b01232cbd to your computer and use it in GitHub Desktop.
Save oleglukashev/12b3d0f2596b01232cbd to your computer and use it in GitHub Desktop.
def solution(text)
result = 0
text.split("").each do |item|
iteration_count = (item == "(") ? 1 : -1
result = result + iteration_count
if result < 0
return 0
end
end
if result == 0
1
else
0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment