← all problems

isBalancedParentheses 🌶️🌶️

Write a method that takes one String parameter, s, made up only of the characters '(' and ')', and returns true if the parentheses are balanced (every close paren has a matching open paren before it, and every open paren is eventually closed), or false otherwise. isBalancedParentheses("(())") returns true. isBalancedParentheses(")(") returns false, even though it has the same number of each character as "()" because the order matters, not just the count.