Check Bracket Correctness
Yandex
Write a function checkBrackets(str) that checks the correctness of bracket placement in a string.
- The string can contain three types of brackets:
Round()
Curly{}
Square[] - The function should return
trueif all brackets are closed and nested correctly, otherwisefalse.
Examples:
Input 1: "{Hi(good day)!}"
Output 1: true
Input 2: "{nice[day}"
Output 2: false
JavaScript•UTF-8
Run your code to see results.
Click the Run button above
Check Bracket Correctness
Yandex
Write a function checkBrackets(str) that checks the correctness of bracket placement in a string.
- The string can contain three types of brackets:
Round()
Curly{}
Square[] - The function should return
trueif all brackets are closed and nested correctly, otherwisefalse.
Examples:
Input 1: "{Hi(good day)!}"
Output 1: true
Input 2: "{nice[day}"
Output 2: false
Run your code to see results.