FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Vanguard logoVanguard● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names Valid Parentheses and links the standard task with three kinds of brackets. Its exact OA input limits and examples are not given. Our version includes the empty string and fixed limits. It is about 95% the same as the named exercise.

Given a string s containing only (, ), [, ], {, and }, determine whether its brackets are valid.

Every opening bracket must close with the same type, and pairs must be properly nested. A closing bracket must match the most recent unmatched opening bracket. Return a boolean.

For this exercise, assume an empty string is valid.

Function

isValidParentheses(s: String) → boolean

Examples

Example 1

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

Both inner pairs close before the surrounding parentheses.

Example 2

s = "([)]"return = false

The closing parenthesis cannot close while the square bracket remains unmatched.

Example 3

s = "(()"return = false

One opening parenthesis remains unmatched.

Constraints

  • For this exercise, assume 0 <= s.length <= 10^5.
  • The input contains only the six listed bracket characters.

More Vanguard Online Assessment questions

  • Two SumOA · Seen Sep 2026
  • Are They PangramsOA · Seen Nov 2025
  • Missing WordsOA · Seen Nov 2025
  • Spam DetectionOA · Seen Nov 2025
  • Binge WatchingOA · Seen Jan 2023
  • Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
  • Maximum Occurring CharacterOA · Seen Mar 2022
  • Picking TicketsOA · Seen Mar 2022
  • Tool List: Two Smallest ValuesOA · Seen Nov 2021
  • Group AnagramsOA · Seen Nov 2019

Similar questions at other companies

  • Validate a Bracket SequenceInMobi · OAInMobi interview questions
  • Valid ParenthesesBlackRock · OABlackRock interview questions
  • Valid Bracket SequenceNVIDIA · OA · PHONE SCREENNVIDIA interview questions
  • Get Final StringIBM · OAIBM interview questions
  • Backspace String CompareGoldman Sachs · OAGoldman Sachs interview questions
  • The PromHackerEarth · OA
  • Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
  • Eliminate SubstringJP Morgan Chase · OAJP Morgan Chase interview questions
  • Balancing ParenthesesOracle · OAOracle interview questions
  • Collapse Equal Adjacent PairsHudson River Trading · OAHudson River Trading interview questions

Interview reports that mention this question

  • Vanguard Tech and Risk Older OAs: 12 Experiences (Part 3 of 3)
  • Vanguard Software Older Rounds: 13 Experiences (Part 2 of 3)
  • Vanguard Tech Intern Interviews: 37 Experiences (Part 1 of 3)
All Vanguard interview questionsSee Vanguard hiring insights
Saved
class Solution {
    public boolean isValidParentheses(String s) {
        // Write your code here.
    }
}
Checking account…