Deepest Nested Substrings
Updated
Problem statement
Given a balanced string containing lowercase letters and the bracket pairs (), [], and {}, return the contents of every bracket pair at the maximum nesting depth.
Return results from left to right. The returned content excludes the surrounding brackets. An empty deepest pair contributes the empty string.
Function
deepestNestedSubstrings(expression: String) → String[]Examples
Example 1
expression = "a[bc]def{cd}"return = ["bc","cd"]Both pairs are at depth one, the maximum depth.
Example 2
expression = "ran(n(d))o(m())"return = ["d",""]The pairs around d and the empty string are the depth-two pairs.
Example 3
expression = "x{a[b(c)d]e}y"return = ["c"]The innermost parentheses are at depth three.
Constraints
0 <= expression.length <= 10^5.- The expression contains lowercase English letters and balanced, correctly matched brackets.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- Adjacent Pair and Run RemovalWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
- Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
- Parse a Partial JSON StreamListen Labs · PHONE SCREEN
- Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
- Number Words to Digits in Any LanguageMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Remove K DigitsProcol · PHONE SCREEN
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)