Question: Write a method that takes a string of curly brackets and returns true if the brackets match up and false if they dont. These are
Write a method that takes a string of curly brackets and returns true if the brackets match up and false if they dont.
These are examples of brackets matching:
{} {}{} {{}} {{{}{{}}}} These are examples of the brackets not matching:
{ }{ {{} {{}}}{} If you are passed the empty string, you should return true.
You can assume the given string will only have { and } in it (or be empty).
public boolean bracketsMatch(String brackets) { }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
