FastPrepValidate a Bracket Sequence
Problems/Validate a Bracket Sequence

Validate a Bracket Sequence

InMobi logoInMobi● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi full-time online assessment. A reported stack task, described as similar to bracket checking, backs this exercise. The original variant was not kept, so we use the usual three bracket types with clear rules for what is valid, and examples with fixed answers. Our version is about 70% the same as the reported question.

Given a string sequence containing only the bracket characters ()[]{}, return whether it is valid.

A valid sequence closes every opening bracket with the same bracket type, and closes brackets in the reverse order in which they were opened.

Function

isValid(sequence: String) → boolean

Examples

Example 1

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

Every closing bracket matches the most recent unmatched opening bracket.

Example 2

sequence = "([)]"return = false

The closing parenthesis appears before the nested square bracket closes.

Constraints

  • 0 <= sequence.length <= 100000.
  • Every character is one of (, ), [, ], {, or }.

Source note: The source image is a source-neutral excerpt of the author-reported prompt.

More InMobi Online Assessment questions

  • Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
  • Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
  • Minimum Service Cold StartsOA · Seen Oct 2026
  • Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
  • Connected Components with Divisor ThresholdOA · Seen Aug 2026
  • Maximize Impression ValueOA · Seen Aug 2026
  • Supply Path OptimizationOA · Seen Aug 2026
  • Delivery ServiceOA · Seen Jun 2026
  • Shared InterestOA · Seen Jun 2026
  • Temporal AnomaliesOA · Seen Jun 2026

Similar questions at other companies

  • 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
  • Eliminate SubstringJP Morgan Chase · OAJP Morgan Chase interview questions
  • Balancing ParenthesesOracle · OAOracle interview questions
  • Balanced Brackets in an ExpressionBank of America · OABank of America interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public boolean isValid(String sequence) {
      // Write your code here.
    }
}
Checking account…