FastPrepValidate Matching Brackets
Problems/Validate Matching Brackets

Validate Matching Brackets

JP Morgan Chase logoJP Morgan Chase● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase full-time online assessment. The commenter says their question was valid parentheses, without giving its statement or input. Our version is about 90% the same as that named kind of task. We chose the alphabet, the limits, a Boolean output and the test data. The commenter does not say which hiring group they were in.

Return true if every opening bracket in text is closed by a bracket of the same type and the pairs are properly nested. Otherwise return false.

The supported pairs are (), [] and {}. Every closing bracket must match the most recent opening bracket that is still unclosed. The empty string is valid.

Function

isValidBrackets(text: String) → boolean

Examples

Example 1

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

The inner braces close first, followed by the square brackets and then the outer parentheses.

Example 2

text = "([)]"return = false

The first closing parenthesis arrives while an opening square bracket is the most recent unmatched opener, so the types are crossed.

Constraints

  • For this exercise, assume 0 <= text.length <= 10000.
  • Every character is one of ( ) [ ] { }. No other characters or spaces occur.

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Invert Ad Visibility BitsOA · Seen Aug 2026

Similar questions at other companies

  • Validate a Bracket SequenceInMobi · OAInMobi interview questions
  • Valid ParenthesesBlackRock · OABlackRock interview questions
  • Valid ParenthesesVanguard · OAVanguard 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
  • Balancing ParenthesesOracle · OAOracle interview questions
  • Collapse Equal Adjacent PairsHudson River Trading · OAHudson River Trading interview questions

Interview reports that mention this question

  • JPMorgan Tech Intern HackerRank OA: 11 Experiences (Part 3 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public boolean isValidBrackets(String text) {
        // Write your code here.
    }
}
Checking account…