|
2 | 2 |
|
3 | 3 | importjava.util.Stack;
|
4 | 4 |
|
5 |
| -/** |
6 |
| - * 1209. Remove All Adjacent Duplicates in String II |
7 |
| - * |
8 |
| - * Given a string s, a k duplicate removal consists of choosing k adjacent and equal |
9 |
| - * letters from s and removing them causing the left and the right side of the deleted substring to concatenate together. |
10 |
| - * We repeatedly make k duplicate removals on s until we no longer can. |
11 |
| - * Return the final string after all such duplicate removals have been made. |
12 |
| - * It is guaranteed that the answer is unique. |
13 |
| - * |
14 |
| - * Example 1: |
15 |
| - * Input: s = "abcd", k = 2 |
16 |
| - * Output: "abcd" |
17 |
| - * Explanation: There's nothing to delete. |
18 |
| - * |
19 |
| - * Example 2: |
20 |
| - * Input: s = "deeedbbcccbdaa", k = 3 |
21 |
| - * Output: "aa" |
22 |
| - * Explanation: |
23 |
| - * First delete "eee" and "ccc", get "ddbbbdaa" |
24 |
| - * Then delete "bbb", get "dddaa" |
25 |
| - * Finally delete "ddd", get "aa" |
26 |
| - * |
27 |
| - * Example 3: |
28 |
| - * Input: s = "pbbcggttciiippooaais", k = 2 |
29 |
| - * Output: "ps" |
30 |
| - * |
31 |
| - * Constraints: |
32 |
| - * 1 <= s.length <= 10^5 |
33 |
| - * 2 <= k <= 10^4 |
34 |
| - * s only contains lower case English letters. |
35 |
| - * */ |
36 | 5 | publicclass_1209 {
|
37 | 6 | publicstaticclassSolution1 {
|
38 | 7 | publicStringremoveDuplicates(Strings,intk) {
|
|