You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: leetcode/3201-3300/3223.Minimum-Length-of-String-After-Operations/README.md
+25-13Lines changed: 25 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,40 @@
1
1
# [3223.Minimum Length of String After Operations][title]
2
2
3
-
> [!WARNING|style:flat]
4
-
> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm)
5
-
6
3
## Description
4
+
You are given a string `s`.
5
+
6
+
You can perform the following process on `s`**any** number of times:
7
+
8
+
- Choose an index `i` in the string such that there is **at least** one character to the left of index `i` that is equal to `s[i]`, and **at least** one character to the right that is also equal to `s[i]`.
9
+
- Delete the **closest** character to the **left** of index `i` that is equal to `s[i]`.
10
+
- Delete the **closest** character to the **right** of index `i` that is equal to `s[i]`.
11
+
12
+
Return the **minimum** length of the final string `s` that you can achieve.
7
13
8
14
**Example 1:**
9
15
10
16
```
11
-
Input: a = "11", b = "1"
12
-
Output: "100"
13
-
```
17
+
Input: s = "abaacbcbb"
14
18
15
-
## 题意
16
-
> ...
19
+
Output: 5
17
20
18
-
## 题解
21
+
Explanation:
22
+
We do the following operations:
19
23
20
-
### 思路1
21
-
> ...
22
-
Minimum Length of String After Operations
23
-
```go
24
+
Choose index 2, then remove the characters at indices 0 and 3. The resulting string is s = "bacbcbb".
25
+
Choose index 3, then remove the characters at indices 0 and 5. The resulting string is s = "acbcb".
24
26
```
25
27
28
+
**Example 2:**
29
+
30
+
```
31
+
Input: s = "aa"
32
+
33
+
Output: 2
34
+
35
+
Explanation:
36
+
We cannot perform any operations, so we return the length of the original string.
0 commit comments