6 kyu
Valid Braces
22,889 of 78,247xDranik
Description:
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
Algorithms
Similar Kata:
Stats:
Created | Nov 4, 2013 |
Published | Nov 5, 2013 |
Warriors Trained | 203614 |
Total Skips | 32874 |
Total Code Submissions | 474631 |
Total Times Completed | 78247 |
JavaScript Completions | 22889 |
CoffeeScript Completions | 228 |
Haskell Completions | 1039 |
C# Completions | 4869 |
Python Completions | 22968 |
Java Completions | 8867 |
Ruby Completions | 1799 |
PHP Completions | 2228 |
TypeScript Completions | 2755 |
Elixir Completions | 292 |
C++ Completions | 5757 |
Dart Completions | 685 |
Rust Completions | 1698 |
Swift Completions | 879 |
Go Completions | 2139 |
Lua Completions | 191 |
Scala Completions | 349 |
C Completions | 594 |
Julia Completions | 27 |
COBOL Completions | 5 |
Total Stars | 3354 |
% of votes with a positive feedback rating | 92% of 7327 |
Total "Very Satisfied" Votes | 6208 |
Total "Somewhat Satisfied" Votes | 1001 |
Total "Not Satisfied" Votes | 118 |