FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Qualys logoQualys● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Qualys onsite interview. The report asks whether a string of brackets is valid. We chose the three kinds of brackets, the result for an empty string, the examples, and the limits.

Given a string s containing only ()[]{}, determine whether its brackets are balanced. Every closing bracket must match the most recent unmatched opening bracket of the same type, and every opening bracket must be closed.

For this exercise, assume the empty string is valid. Return a boolean.

Function

validParentheses(s: String) → boolean

Examples

Example 1

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

Each pair has the correct type, and the square brackets close before their enclosing parentheses.

Example 2

s = "([)]"return = false

The first closing parenthesis encounters an unmatched opening square bracket, so the nesting is invalid.

Constraints

  • For this exercise, assume 0 <= s.length <= 10^5.
  • Every character is one of ( ) [ ] { }.

More Qualys Onsite Interview questions

  • Delete a Doubly Linked List Node at a PositionONSITE INTERVIEW · Seen Oct 2026
  • Find the Entry of a Linked List CycleONSITE INTERVIEW · Seen Oct 2026
  • Implement Binary SearchONSITE INTERVIEW · Seen Oct 2026
  • Insert a Doubly Linked List Node at a PositionONSITE INTERVIEW · Seen Oct 2026
  • Rotate an Array Right by K StepsONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Valid ParenthesesKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Parenthesis Removals and Their IndicesDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Parenthesis Nesting DepthRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Valid ParenthesesZillow · PHONE SCREEN · ONSITE INTERVIEWZillow interview questions
All Qualys interview questionsSee Qualys hiring insights
Saved
class Solution {
    public boolean validParentheses(String s) {
        // Write your solution here.
    }
}
Checking account…