454. Non-Allergic String
0
Medium
Bob is allergic to strings that contain adjacent characters of the same type, with a total of k duplicates.
You are given a string s and an integer k. A k duplicate removal involves selecting k adjacent and identical letters from s and removing them, resulting in the concatenation of the remaining characters on both sides of the deleted substring. Repeat the process of k duplicate removals on s until it is no longer possible.
Print the final Non - Allergic String.
You are given a string s and an integer k. A k duplicate removal involves selecting k adjacent and identical letters from s and removing them, resulting in the concatenation of the remaining characters on both sides of the deleted substring. Repeat the process of k duplicate removals on s until it is no longer possible.
Print the final Non - Allergic String.
Input Format
The first line contains a single integer k.
The second line contains a string s
The second line contains a string s
Output Format
Print a Non- Allergic string
Example
Input
2
CooodddingBlllllocks
Output
CodingBlocks
Constraints
1 <= <= 104
1 <= k <= N
1 <= k <= N
Loading...
View Submissions
Console