|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1047. Remove All Adjacent Duplicates In String |
5 |
| - * |
6 |
| - * Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. |
7 |
| - * |
8 |
| - * We repeatedly make duplicate removals on S until we no longer can. |
9 |
| - * |
10 |
| - * Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique. |
11 |
| - * |
12 |
| - * |
13 |
| - * |
14 |
| - * Example 1: |
15 |
| - * |
16 |
| - * Input: "abbaca" |
17 |
| - * Output: "ca" |
18 |
| - * Explanation: |
19 |
| - * For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move. |
20 |
| - * The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca". |
21 |
| - * |
22 |
| - * |
23 |
| - * Note: |
24 |
| - * |
25 |
| - * 1 <= S.length <= 20000 |
26 |
| - * S consists only of English lowercase letters.*/ |
27 | 3 | publicclass_1047 {
|
28 | 4 | publicstaticclassSolution1 {
|
29 | 5 | publicStringremoveDuplicates(StringS) {
|
|