Step 9 of 12 · Stacks

Balanced brackets

IntermediateJavaScript1,000 ms

Problem

Read a string containing only (), [], and {}. Return "Balanced" when every opening bracket closes in the correct order, otherwise return "Not balanced".

Input

One non-empty string containing only bracket characters.

Output

The exact words "Balanced" or "Not balanced".

Examples

Input
{[()]}
Output
Balanced

Every closing bracket matches the latest unmatched opening.

Input
([)]
Output
Not balanced

The pairs cross instead of closing in stack order.

Browser-isolated runner

Write your solution.

Define solve(input) and return the exact output. Network access is blocked and the runner stops after 1,000 ms. Run the example to inspect local console.log output.

Best verdictNot submitted
solution.jsLocal only
Keyboard: Tab to Run, then EnterSign in to submit
Try your own inputRuns locally without adding a saved attempt
Ready

You can run the example now. Sign in to submit and save progress.

Sign in to save this work. Your code, attempts, and Accepted progress return with your account.

Saved attempts

Verdict history

No saved submissions yet. Your first verdict will appear here.