#28 Valid Braces


Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if the string is valid, and false if it's invalid.


This Kata is similar to the Valid Parentheses Kata, but introduces new characters: brackets [], and curly braces {}. Thanks to @arnedag for the idea!


All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: ()[]{}.


What is considered Valid?

A string of braces is considered valid if all braces are matched with the correct brace.


Examples


"(){}[]"   =>  True

"([{}])"   =>  True

"(}"       =>  False

"[(])"     =>  False

"[({})](]" =>  False



'매일매일개발 > Codewars' 카테고리의 다른 글

codewars #30 Psychic (3kyu)  (1) 2018.04.27
codewars #29 Multiples of 3 or 5 (6kyu)  (0) 2018.04.26
codewars #27 Follow that Spy (6kyu)  (0) 2018.04.24
오늘은 하루 쉼  (0) 2018.04.23
codewars #26 lucky number (7kyu)  (1) 2018.04.20

+ Recent posts