CJCoding With Joseph
15free / daySign inCreate account

Check for Balanced Brackets

A stack is the classic way to check bracket nesting: an opener waits on the stack until its own closer shows up. The Deque and the character loop are already set up.

Requirements:
1. Complete isBalanced(String text) for the pairs ( ), [ ] and { }.
2. Push every opener. On a closer, the item popped must be its matching opener.
3. Return false on a closer with nothing to match, and true only when nothing is left waiting.
4. Ignore every other character, so text with no brackets is balanced.

Do NOT write a main method.

Expected Output:

true
false
false
true

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Data Structures & AlgorithmsStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.