https://github.com/jsonzilla/balanced_brackets
The already classic interview toy project for test logical of our applicants
https://github.com/jsonzilla/balanced_brackets
interview-questions logic
Last synced: 4 months ago
JSON representation
The already classic interview toy project for test logical of our applicants
- Host: GitHub
- URL: https://github.com/jsonzilla/balanced_brackets
- Owner: jsonzilla
- License: lgpl-3.0
- Created: 2021-05-08T15:27:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-11T19:45:54.000Z (over 3 years ago)
- Last Synced: 2025-03-22T04:27:12.558Z (12 months ago)
- Topics: interview-questions, logic
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Balanced Brackets
A function that takes a string of brackets as the input, and determines if the order of
the brackets is valid. A bracket is considered to be any one of the following characters: ```(, ),
{, }, [,``` or ```]```.
We say a sequence of brackets is valid if the following conditions are met:
* It contains no unmatched brackets.
* The subset of brackets enclosed within the confines of a matched pair of brackets is
also a matched pair of brackets.
Examples:
* ```(){}[]``` is valid
* ```[{()}](){}``` is valid
* ```[]{()``` is not valid
* ```[{)]``` is not valid
## Install
```
npm install
npm test
```
## Expected
```
TAP version 13
# Balanced Brackers {()}[]
ok 1 should be truthy
# Balanced Brackers (){}[]
ok 2 should be truthy
# Balanced Brackers (){}[]
ok 3 should be truthy
# Balanced Brackers {(a())*8+[fd()^^r()]}
ok 4 should be truthy
# Balanced Brackers []{()
ok 5 should be truthy
# Balanced Brackers [{)]
ok 6 should be truthy
# Balanced Brackers [{(}))]
ok 7 should be truthy
# Balanced Brackers [{(})])
ok 8 should be truthy
1..8
# tests 8
# pass 8
# ok
```