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/2901-3000/2914.Minimum-Number-of-Changes-to-Make-Binary-String-Beautiful/README.md
+29-13Lines changed: 29 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,44 @@
1
1
# [2914.Minimum Number of Changes to Make Binary String Beautiful][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 **0-indexed** binary string `s` having an even length.
5
+
6
+
A string is **beautiful** if it's possible to partition it into one or more substrings such that:
7
+
8
+
- Each substring has an **even length**.
9
+
- Each substring contains **only**`1`'s or **only**`0`'s.
10
+
11
+
You can change any character in `s` to `0` or `1`.
12
+
13
+
Return the **minimum** number of changes required to make the string `s` beautiful.
7
14
8
15
**Example 1:**
9
16
10
17
```
11
-
Input: a = "11", b = "1"
12
-
Output: "100"
18
+
Input: s = "1001"
19
+
Output: 2
20
+
Explanation: We change s[1] to 1 and s[3] to 0 to get string "1100".
21
+
It can be seen that the string "1100" is beautiful because we can partition it into "11|00".
22
+
It can be proven that 2 is the minimum number of changes needed to make the string beautiful.
13
23
```
14
24
15
-
## 题意
16
-
> ...
25
+
**Example 2:**
17
26
18
-
## 题解
19
-
20
-
### 思路1
21
-
> ...
22
-
Minimum Number of Changes to Make Binary String Beautiful
23
-
```go
24
27
```
28
+
Input: s = "10"
29
+
Output: 1
30
+
Explanation: We change s[1] to 1 to get string "11".
31
+
It can be seen that the string "11" is beautiful because we can partition it into "11".
32
+
It can be proven that 1 is the minimum number of changes needed to make the string beautiful.
33
+
```
34
+
35
+
**Example 3:**
25
36
37
+
```
38
+
Input: s = "0000"
39
+
Output: 0
40
+
Explanation: We don't need to make any changes as the string "0000" is beautiful already.
0 commit comments