FastPrepMaximum Parenthesis Nesting Depth
Problems/Maximum Parenthesis Nesting Depth

Maximum Parenthesis Nesting Depth

Rippling logoRippling● EasyINTERNNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Rippling intern and new grad phone screen. The report asks for the deepest nesting of parentheses. We chose balanced input, the limits, and the examples. Our version is about 90% the same as the reported question.

Given a string expression with balanced parentheses, return its maximum nesting depth: the greatest number of open parenthesis pairs at any position.

Only ( and ) affect the depth. All other characters are ignored. An expression with no parentheses has depth 0.

Function

maxDepth(expression: String) → int

Examples

Example 1

expression = "a*(b+(c*d))"return = 2

The parentheses around c*d are inside one other pair.

Example 2

expression = "()(())"return = 2

Separate groups do not add their depths; the deepest group has two pairs.

Example 3

expression = "plain text"return = 0

There is no open parenthesis.

Constraints

  • 0 <= expression.length <= 10^5.
  • The string contains printable ASCII characters.
  • Its parentheses are balanced.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Valid ParenthesesByteDance · PHONE SCREENByteDance interview questions
  • Valid ParenthesesCisco · PHONE SCREENCisco interview questions
  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Valid ParenthesesQualys · ONSITE INTERVIEWQualys interview questions
  • Validate a Bracket SequenceTripAdvisor · PHONE SCREEN
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesOracle · PHONE SCREENOracle interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW

Interview reports that mention this question

  • Rippling New Grad SDE Interviews: 11 Experiences
  • Rippling Intern Phone Screens: 28 Experiences (Part 3 of 5)
  • Rippling SWE Intern Interviews: 101 Experiences (Part 1 of 5)

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int maxDepth(String expression) {
        // Write your code here.
    }

}
Checking account…