
This was a Bloomberg 26NG Superday coding problem. The algorithm is straightforward, but communication quality is what really differentiates candidates.
Clarifications first
I would confirm two points up front:
- Is the parentheses string always valid? Yes.
- Can the content inside parentheses be empty?
Yes, e.g.
().
These clarifications keep the implementation focused.
Improved interview wording (ready to say)
I scan left to right and maintain three states:
depth: current nesting depthmaxDepth: maximum depth seen so farcurr: substring collected for the current nesting layer (excluding outer parentheses)
Rules while scanning:
On
'(': Increasedepthand start collecting for a deeper layer. Deeper layers are the only candidates for larger depth answers.On
')': We are about to leave the current layer. Ifdepth > maxDepth, clear previous answers, addcurr, and updatemaxDepth. Ifdepth == maxDepth, appendcurr. Then clearcurrand decrementdepth.On normal characters: Append to
curr.
At the end, return all substrings associated with maximum depth (format depends on the prompt).
Complexity
- Time:
O(n) - Space:
O(n)(result + temporary substring)
Common pitfalls
- Updating
depthandmaxDepthin the wrong order - Forgetting to clear old answers when a new deeper level appears
- Failing empty-content cases like
() - Accidentally including outer parentheses in returned substrings
3 practical BQ prompts (for Bloomberg Superday)
BQ1: Tell me about a time you fixed a high-pressure issue quickly
Structure:
- Situation: critical bug/outage context
- Action: triage, isolate, patch, monitor
- Result: recovery time and prevention improvements
BQ2: Tell me about a disagreement with a teammate
Structure:
- Conflict: what exactly differed
- Action: align goals, define metrics, run a small validation
- Result: data-driven decision and team learning
BQ3: Tell me about a time you improved efficiency proactively
Structure:
- Bottleneck you identified
- Change you designed and shipped
- Measurable impact (time saved, error reduction, throughput)
Takeaway
This problem is essentially one-pass state tracking. In Bloomberg-style interviews, correctness matters, but clear state reasoning and edge-case communication matter just as much.
If you are preparing for Bloomberg / Google / Amazon interviews, feel free to reach out.
#bloomberg #superday #vo #newgrad #sde #interview
Further Reading (External Links)
Need real interview questions? Contact WeChat Coding0201: Get Questions.
Contact
Email: [email protected]
Telegram: @OAVOProxy