FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Cisco logoCisco● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In a Cisco interview for a second role, both rounds asked the classic valid parentheses question: check whether a string of brackets is balanced.

The post names the question but gives no limits or examples. This version uses the usual three bracket types and strings of 1 to 10^4 characters.

Our version is about 95% the same as the reported question.

You are given a string s made only of the characters (, ), [, ], { and }. Return true if the brackets are valid, and false otherwise.

The brackets are valid when:

  • every opening bracket is closed by a bracket of the same type,
  • brackets are closed in the correct order, so the most recently opened bracket closes first, and
  • every closing bracket has a matching opening bracket before it.

Function

isValid(s: String) → boolean

Examples

Example 1

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

The ( closes first, then [, then {. Each closes the most recent open bracket of the same type, so the string is valid.

Example 2

s = "([)]"return = false

When ) arrives, the most recent open bracket is [, not (. The order is wrong, so the string is not valid.

Example 3

s = "(()"return = false

The first ( is never closed, so the string is not valid.

Constraints

  • 1 <= s.length <= 10^4
  • s contains only ()[]{}.

More Cisco interview questions

  • Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
  • Find Unique ElementsPHONE SCREEN · Seen Nov 2026
  • First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
  • Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a StringPHONE SCREEN · Seen Nov 2026
  • K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
  • Longest Non-Repeating SubstringPHONE SCREEN · Seen Jul 2026
  • Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
  • Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Valid ParenthesesByteDance · PHONE SCREENByteDance interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Validate a Bracket SequenceTripAdvisor · PHONE SCREEN
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesOracle · PHONE SCREENOracle interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Balanced Bracket String CheckRippling · PHONE SCREENRippling interview questions
  • Valid Bracket SequenceNVIDIA · OA · PHONE SCREENNVIDIA interview questions
  • Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Valid ParenthesesPeopleStrong · PHONE SCREENPeopleStrong interview questions
All Cisco interview questionsSee Cisco hiring insights
Saved
class Solution {
    public boolean isValid(String s) {
        // Write your code here.
    }
}
Checking account…