Problem Overview
"Remove All Adjacent Duplicates in String II" is a Meta (Facebook) coding interview problem tagged with String and Stack. You are given a string s and an integer k, and must repeatedly remove k adjacent identical characters until no more removals are possible, with remaining string parts concatenating afterward.[5][9]
Full Problem Statement
Given a string s and integer k, perform k duplicate removals: choose k adjacent equal letters from s and remove them, causing left and right parts to join. Repeat until no such group exists. Return the final string.[2][9][5]
Examples
Input: s = "deeedbbcccbdaa", k = 3
Output: "a"
Explanation: Remove "eee" → "ddbbcccbdaa"; remove "bbb" → "ddcccbdaa"; remove "ccc" → "dddda"; remove "ddd" → "a".[2][5]
Input: s = "pbbcggttciiippp", k = 2
Output: "pbc"
Explanation: Remove "pp" → "bbcggttciiippp"; remove "bb" → "ccggttciiippp"; remove "tt" → "ccggiiippp"; remove "cc" → "ggiiippp"; remove "gg" → "iiippp"; remove "iii" → "ppp".[5]
Input: s = "deeedbbcccbdaa", k = 1 (edge case implied)
Output: "" (all single chars removed iteratively).[3]
Constraints
1 <= s.length <= 10^51 <= k <= s.lengths consists of lowercase English letters.[1][5]