FastPrepValid Bracket Sequence
Problems/Valid Bracket Sequence

Valid Bracket Sequence

NVIDIA logoNVIDIA● EasyFULLTIMEINTERNOAPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A NVIDIA applied-research intern report tentatively recalls a very simple OA resembling valid parentheses. The exact bracket set and rules were not reported. This practice uses the conventional three bracket pairs and a stack; it matches the reported core at about 55%.

Given a string s containing only the bracket characters ()[]{}, determine whether it is a valid bracket sequence.

Every opening bracket must be closed by the same bracket type, and closing brackets must appear in the reverse order of their matching openings. A closing bracket without a prior unmatched opening is invalid. The empty string is valid.

Function

isValidBracketSequence(s: String) → boolean

Examples

Example 1

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

Each closer matches the newest unmatched opener of the same type.

Example 2

s = "([)]"return = false

The closing parenthesis arrives while the square bracket is still open.

Example 3

s = "((("return = false

Three opening brackets remain unmatched.

Example 4

s = ""return = true

There are no unmatched brackets in the empty sequence.

Constraints

  • 0 <= s.length <= 100000.
  • Every character is one of (, ), [, ], {, or }.

More NVIDIA problems

  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Query a Header-Encoded MatrixOA · Seen Oct 2026
  • Maximum ScoreOA · Seen Oct 2026
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
public boolean isValidBracketSequence(String s) {
    // Write your code here.
}
Checking account…