FastPrepMinimum Remove to Make Valid Parentheses
Problems/Minimum Remove to Make Valid Parentheses

Minimum Remove to Make Valid Parentheses

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the usual stack-based exercise but gives no limits, and it does not say which answer to return when several are equally short. Our version is about 92% the same as the reported question.

Given a string s containing ASCII letters, digits, opening parentheses, and closing parentheses, remove the minimum possible number of parentheses so that the remaining parentheses are balanced. You may not add or reorder characters.

When several results remove the same number of parentheses, use this rule:

  1. Scan from left to right. Discard every closing parenthesis that has no unmatched opening parenthesis before it.
  2. After that scan, discard the still-unmatched opening parentheses from right to left.

Return the retained characters in their original relative order. Letters and digits are always retained.

Function

minRemoveToMakeValid(s: String) → String

Examples

Example 1

s = "lee(t(c)o)de)"return = "lee(t(c)o)de"

The final closing parenthesis has no matching opening parenthesis, so removing it produces a balanced result with one deletion.

Example 2

s = "a)b(c)d"return = "ab(c)d"

The closing parenthesis after a is unmatched during the left-to-right scan. Every other parenthesis can be retained.

Example 3

s = "))(("return = ""

Both closing parentheses are unmatched, and both opening parentheses remain unmatched, so all four are removed.

Constraints

  • 1 <= s.length <= 100000.
  • s contains only ASCII letters, digits, (, and ).

More Bloomberg LP Onsite Interview questions

  • 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
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Remove K DigitsProcol · PHONE SCREEN
  • Remove K DigitsThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Remove K DigitsAmazon · ONSITE INTERVIEW
  • Minimum Removal for Balanced ParenthesesMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Largest K-Digit SubsequenceGoogle · ONSITE INTERVIEWGoogle interview questions
  • Remove K DigitsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Smallest Number After Removing k DigitsAdobe · PHONE SCREENAdobe interview questions
  • Lexicographically Largest Distinct-Letter SubsequenceNavan · PHONE SCREENNavan interview questions
  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Modify the StringYahoo · OAYahoo interview questions

Interview reports that mention this question

  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad Interviews: 2025 vs 2026 Guide
  • Bloomberg New Grad VOs: 32 Experiences (Part 5 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String minRemoveToMakeValid(String s) {
        // Write your code here.
    }

}
Checking account…