7 kyu
Valid Parentheses
2,708 of 8,938Kacarott
Description:
Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true
if the string is valid, and false
if it's invalid.
Examples
"()" => true
")(()))" => false
"(" => false
"(())((()())())" => true
Constraints
0 <= length of input <= 100
- All inputs will be strings, consisting only of characters
(
and)
. - Empty strings are considered balanced (and therefore valid), and will be tested.
- For languages with mutable strings, the inputs should not be mutated.
Protip: If you are trying to figure out why a string of parentheses is invalid, paste the parentheses into the code editor, and let the code highlighting show you!
Strings
Parsing
Algorithms
Similar Kata:
Stats:
Created | Mar 15, 2023 |
Published | Mar 15, 2023 |
Warriors Trained | 15209 |
Total Skips | 226 |
Total Code Submissions | 24542 |
Total Times Completed | 8938 |
Python Completions | 2708 |
Rust Completions | 221 |
C Completions | 258 |
Java Completions | 1001 |
JavaScript Completions | 2865 |
Julia Completions | 22 |
C++ Completions | 1263 |
Factor Completions | 12 |
C# Completions | 459 |
Swift Completions | 222 |
Haskell Completions | 90 |
Scala Completions | 49 |
CoffeeScript Completions | 12 |
COBOL Completions | 5 |
Kotlin Completions | 80 |
TypeScript Completions | 130 |
Total Stars | 206 |
% of votes with a positive feedback rating | 93% of 762 |
Total "Very Satisfied" Votes | 673 |
Total "Somewhat Satisfied" Votes | 72 |
Total "Not Satisfied" Votes | 17 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |