https://github.com/yankouskia/additional_5
Brackets
https://github.com/yankouskia/additional_5
Last synced: 14 days ago
JSON representation
Brackets
- Host: GitHub
- URL: https://github.com/yankouskia/additional_5
- Owner: yankouskia
- License: mit
- Created: 2017-02-17T18:35:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-20T09:13:02.000Z (over 2 years ago)
- Last Synced: 2025-04-11T05:09:12.254Z (14 days ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 8,227
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Brackets
## Task
Implement function `check(str, bracketsConfig)`, that for given brackets sequence will return `true` if it is correct and `false` otherwise
In the second param there is `bracketsConfig` - the array of pairs open-closed brackets. Each subarray includes only 2 elements - opening and closing bracket
```js
check('()', [['(', ')']]) // -> true
check('((()))()', [['(', ')']]) // -> true
check('())(', [['(', ')']]) // -> false
check('([{}])', [['(', ')'], ['[', ']'], ['{', '}']]) // -> true
check('[(])', [['(', ')'], ['[', ']']]) // -> false
check('[]()', [['(', ')'], ['[', ']']]) // -> true
check('[]()(', [['(', ')'], ['[', ']']]) // -> false// special case: opening and closing bracket can be the same :)
check('||', [['|', '|']]) // -> true
check('|()|', [['(', ')'], ['|', '|']]) // -> true
check('|(|)', [['(', ')'], ['|', '|']]) // -> false
check('|()|(||)||', [['(', ')'], ['|', '|']]) // -> true
```Write your code in `src/index.js`