Tap here to switch tabs
Problem
Submissions

Problem: Remove All Adjacent Duplicates in String II

Remove All Adjacent Duplicates in String II gives you a string and a number k. Repeatedly remove groups of k identical adjacent characters and return the unique string left.

Statement

Given a string s and an integer k, a k-duplicate removal involves selecting k adjacent and equal characters from s and removing them, after which the left and right portions of the string are joined together.

Perform k-duplicate removals on s repeatedly until no more can be made.

Return the final string after all such removals. The answer is guaranteed to be unique.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • 2≤2 \leq k ≤104\leq 10^4

  • s contains only lowercase English letters

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Remove All Adjacent Duplicates in String II

Remove All Adjacent Duplicates in String II gives you a string and a number k. Repeatedly remove groups of k identical adjacent characters and return the unique string left.

Statement

Given a string s and an integer k, a k-duplicate removal involves selecting k adjacent and equal characters from s and removing them, after which the left and right portions of the string are joined together.

Perform k-duplicate removals on s repeatedly until no more can be made.

Return the final string after all such removals. The answer is guaranteed to be unique.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • 2≤2 \leq k ≤104\leq 10^4

  • s contains only lowercase English letters