Kotlinlearncs.online LogoJava
Return to List

Solve: Validate Brackets

Created By: Justin Maier
/ Version: 2024.12.0

Complete the method below that takes in a String containing only the enclosing characters '(', ')', '[', and ']'. The function should determine whether the ordering and pairing of the brackets form a valid expression. For example,

  • "[()]" is valid.
  • "[()[]" is not valid since the first bracket '[' is not matched.
  • "[(])" is not valid as the outer closing bracket ']' occurs before the inner closing bracket ')'.
boolean validBrackets(String input) {
return false; // You may need to remove this starter code
}

Related Lessons

Stuck? You may find these lessons helpful: