FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

PeopleStrong logoPeopleStrong● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong phone screen. The candidate reports Valid Parentheses with a stack dry run and edge cases. We chose the limits and the result for an empty string. Our version is about 95% the same as the reported question.

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 PeopleStrong Phone Screen questions

  • Reverse Linked-List Nodes in Groups of KOA · PHONE SCREEN · Seen Mar 2026
  • Level of the Minimum-Sum SubtreePHONE SCREEN · Seen Jan 2026
  • Ceiling Value in a Sorted ArrayPHONE SCREEN · Seen Sep 2025
  • Maximum Employee Salary for a CompanyPHONE SCREEN · Seen Sep 2025
  • Number of ProvincesPHONE SCREEN · Seen May 2025
  • Shortest Subarray with an Exact Target SumPHONE SCREEN · Seen May 2025
  • Add Forward Linked-List Numbers Using RecursionPHONE SCREEN · Seen Oct 2021
  • Running Median of a StreamPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2021
  • Build an Expression Tree from PostfixPHONE SCREEN · Seen Oct 2021
  • Maximum Score from Deleting Neighboring ValuesPHONE SCREEN · Seen Oct 2021

Similar questions at other companies

  • Valid ParenthesesByteDance · PHONE SCREEN
  • Valid ParenthesesCisco · PHONE SCREEN
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Validate a Bracket SequenceTripAdvisor · PHONE SCREEN
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEW
  • Valid ParenthesesOracle · PHONE SCREEN
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Balanced Bracket String CheckRippling · PHONE SCREEN
  • Valid Bracket SequenceNVIDIA · OA · PHONE SCREEN
  • Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEW
See PeopleStrong hiring insights
Saved
class Solution {
    public boolean validParentheses(String s) {
        // Write your solution here.
    }
}
Checking account…