As reported: PayPal Senior Software Engineer (Python), DSA round (2025): LeetCode Remove All Adjacent Duplicates in String II, solved with a stack.
Given a string s and an integer k, a k-duplicate removal deletes k adjacent equal letters, joining the left and right parts. Repeat removals until none is possible and return the final string (it is unique).
This is LeetCode 1209 — Remove All Adjacent Duplicates in String II.
Example 1
s = "abcd", k = 2 -> "abcd"
Example 2
s = "deeedbbcccbdaa", k = 3 -> "aa"
Example 3
s = "pbbcggttciiippooaais", k = 2 -> "ps"
Constraints: 1 ≤ s.length ≤ 10^5; 2 ≤ k ≤ 10^4; s has only lowercase English letters.
Code runner format: one JSON value per line: s, then k. Implement removeDuplicates(s, k); the harness prints the result.