rolling-scopes-school/additional_5

Name: additional_5

Owner: Rolling Scopes School

Description: Brackets

Created: 2017-09-25 09:36:54.0

Updated: 2017-09-25 09:36:56.0

Pushed: 2017-09-20 11:31:01.0

Homepage: null

Size: 4

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

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

k('()', [['(', ')']]) // -> true
k('((()))()', [['(', ')']]) // -> true
k('())(', [['(', ')']]) // -> false
k('([{}])', [['(', ')'], ['[', ']'], ['{', '}']]) // -> true
k('[(])', [['(', ')'], ['[', ']']]) // -> false
k('[]()', [['(', ')'], ['[', ']']]) // -> true
k('[]()(', [['(', ')'], ['[', ']']]) // -> false

pecial case: opening and closing bracket can be the same :)

k('||', [['|', '|']]) // -> true
k('|()|', [['(', ')'], ['|', '|']]) // -> true
k('|(|)', [['(', ')'], ['|', '|']]) // -> false
k('|()|(||)||', [['(', ')'], ['|', '|']]) // -> true

Write your code in src/index.js


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.