FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Expedia logoExpedia● EasyNEW GRADINTERNOAONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The bracket-matching rule is reported directly. One additional assessment account takes a vector of strings and returns a vector of answers, while this practice judges one string at a time. Applying the function to each item is an interface adaptation; numeric limits are practice assumptions. Estimated source match 90%.

Given a string s containing only parentheses, square brackets, and braces, return whether it is valid.

  • Every opening bracket must be closed by the same kind of bracket.
  • Brackets must close in the reverse order in which they open.
  • Every closing bracket must have a matching opening bracket.

The empty string is valid.

Function

isValid(s: String) → boolean

Examples

Example 1

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

The square brackets close inside the parentheses. The final pair of braces is also matched, so every bracket closes in the required order.

Example 2

s = "([)]"return = false

The closing parenthesis arrives while the most recent opening bracket is a square bracket. These kinds do not match.

Constraints

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

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Valid ParenthesesQualys · ONSITE INTERVIEWQualys interview questions
  • Validate a Bracket SequenceInMobi · OAInMobi interview questions
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesBlackRock · OABlackRock interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Valid ParenthesesKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesVanguard · OAVanguard interview questions
  • Valid ParenthesesSalesforce · ONSITE INTERVIEWSalesforce interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public boolean isValid(String s) {
        // Write your solution here.
    }
}
Checking account…