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

Stats:

CreatedMar 15, 2023
PublishedMar 15, 2023
Warriors Trained15209
Total Skips226
Total Code Submissions24542
Total Times Completed8938
Python Completions2708
Rust Completions221
C Completions258
Java Completions1001
JavaScript Completions2865
Julia Completions22
C++ Completions1263
Factor Completions12
C# Completions459
Swift Completions222
Haskell Completions90
Scala Completions49
CoffeeScript Completions12
COBOL Completions5
Kotlin Completions80
TypeScript Completions130
Total Stars206
% of votes with a positive feedback rating93% of 762
Total "Very Satisfied" Votes673
Total "Somewhat Satisfied" Votes72
Total "Not Satisfied" Votes17
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Kacarott Avatar
  • JohanWiltink Avatar
  • Madjosz Avatar
  • Awesome A.D. Avatar
  • hobovsky Avatar
  • kirull Avatar
  • ejini战神 Avatar
  • depial Avatar
  • dfhwze Avatar
  • HartlIKS Avatar
  • LosBlobbos Avatar
Ad