FastPrepRemove Adjacent Duplicates in String II
Problems/Remove Adjacent Duplicates in String II

Remove Adjacent Duplicates in String II

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a firsthand Bloomberg entry-level phone screen. You keep removing runs of exactly k equal neighboring characters.

Given a lowercase string s and an integer k, repeatedly remove any group of exactly k adjacent equal characters. Concatenate the remaining parts after each removal.

Return the unique final string after no removable group remains.

Function

removeDuplicates(s: String, k: int) → String

Examples

Example 1

s = "deeedbbcccbdaa"k = 3return = "aa"

Removing eee and ccc makes the three b characters adjacent. Removing them leaves aa.

Example 2

s = "pbbcggttciiippooaais"k = 2return = "ps"

Each adjacent pair is removed as it forms, including pairs created by earlier removals.

Example 3

s = "abcd"k = 2return = "abcd"

No two adjacent characters are equal.

Constraints

  • 1 <= s.length <= 100000.
  • s contains only lowercase English letters.
  • 2 <= k <= s.length.

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 New Grad Question Bank: 161 Questions (Part 1 of 2)
  • Bloomberg New Grad VOs: 32 Experiences (Part 5 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

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
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String removeDuplicates(String s, int k) {
      // Write your code here.
    }
}
Checking account…