Tap here to switch tabs
Problem
Submissions

Problem: Apply Operations to Make String Empty

Apply Operations to Make String Empty asks you to repeatedly remove the first occurrence of each distinct character, then return the string that remains before the final removal.

Statement

You are given a string s.

In one operation, you simultaneously remove the first occurrence of every distinct character present in s. This process is repeated until the string becomes empty.

Return the string s immediately before the last operation that makes it empty.

Constraints:

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

  • s consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Apply Operations to Make String Empty

Apply Operations to Make String Empty asks you to repeatedly remove the first occurrence of each distinct character, then return the string that remains before the final removal.

Statement

You are given a string s.

In one operation, you simultaneously remove the first occurrence of every distinct character present in s. This process is repeated until the string becomes empty.

Return the string s immediately before the last operation that makes it empty.

Constraints:

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

  • s consists only of lowercase English letters.