FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

BlackRock logoBlackRock● EasyNEW GRADINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report names the canonical bracket-validation task. This practice version states the conventional bracket alphabet, nesting rule, and empty-input behavior.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question appeared again on September 30, 2026! (∩˃o˂∩)♡ 🩵

Given a string s containing only (, ), [, ], {, and }, return whether it is valid.

A string is valid when every opening bracket is closed by the same bracket type and brackets close in the correct nested order. The empty string is valid.

Function

isValidParentheses(s: String) → boolean

Examples

Example 1

s = "([]{})"return = true

Every bracket closes in the reverse order in which it opened.

Example 2

s = "([)]"return = false

The closing parenthesis appears before the square bracket is closed.

Constraints

  • 0 <= s.length <= 100000.
  • s contains only the six bracket characters listed above.

More BlackRock problems

  • Find Minimum TimeOA · Seen Nov 2026
  • Count LevelsOA · Seen Sep 2026
  • Lowest Common Ancestor in a Parent TreeOA · Seen Sep 2026
All BlackRock interview questionsSee BlackRock hiring insights
Saved
class Solution {
    public boolean isValidParentheses(String s) {
        // Write your code here.
    }
}
Checking account…