forked from dario-valles/algo-balanced-brackets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (25 loc) · 1016 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Balanced parentheses (20 mins)
// CHALLENGE
// Write a function called `balanced` that accepts
// 1 string with only 6 valid cahracters ({}[]()). The function
// should return true or false if the string has blanaced characters
// e.g. `balanced('((({}[])))') ===> true`
// Consider all brackets, parenthesis and curly braces should be i order
// For example '(}{)' This should return false but '({})' should return true
// EXAMPLES
// balanced('()') => true
// balanced('()(') => false
// balanced('()()') => true
// balanced('({})') => true
// balanced('(([{}]{}))) => true
// balanced('{}[](}{})') => false
// TESTING YOUR SOLUTION
// To test your solution, run 'npm install' in the root directory
// and then run 'npm test' to run the automated tests.
// SUBMITTING YOUR SOLUTION
// When done, make sure you're working on a forked repo, push your
// changes to your forked repo and submit a pull request.
const balanced = str => {
// your code here. Enjoy the music.
};
module.exports = balanced;