Tap here to switch tabs
Problem
Submissions

Problem: Merge Close Characters

med
30 min
Try to solve the Merge Close Characters problem.

Statement

You are given a string s and an integer k.

Two identical characters at indices i and j (where i << j) are considered close if j−i≤kj - i \leq k.

While there exists a pair of close characters, merge them by eliminating the character at index j. Repeat this process until no two identical characters are at a distance of at most k.

Return the final string after all possible merges have been made.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • 1≤1 \leq k ≤\leq s.length

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Merge Close Characters

med
30 min
Try to solve the Merge Close Characters problem.

Statement

You are given a string s and an integer k.

Two identical characters at indices i and j (where i << j) are considered close if j−i≤kj - i \leq k.

While there exists a pair of close characters, merge them by eliminating the character at index j. Repeat this process until no two identical characters are at a distance of at most k.

Return the final string after all possible merges have been made.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • 1≤1 \leq k ≤\leq s.length

  • s consists of lowercase English letters.