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: app/docs/CommunityShare/Leetcode/1653. 使字符串平衡的最少删除次数_translated.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
---
2
2
title: 1653. The minimum number of times to balance the string balance.md
3
-
date: '2024.01.01 0:00'
3
+
date: "2024.01.01 0:00"
4
4
tags:
5
5
- - Python
6
6
- - answer
7
7
abbrlink: cac21f27
8
+
docId: bsf0yz1zrmlz7masrdmq8fq6
8
9
---
9
10
10
11
# topic:
@@ -13,7 +14,7 @@ abbrlink: cac21f27
13
14
14
15
# Thought:
15
16
16
-
ask:Why if-else Write (c - 'a') * 2 - 1 It will be much faster?
17
+
ask:Why if-else Write (c - 'a') \* 2 - 1 It will be much faster?
17
18
18
19
answer:CPU I encounter a branch(Condition jump instruction)Which branch of the code will be predicted when the code is executed,If the prediction is correct,
19
20
CPU It will continue to execute the program in accordance with the predicted path。But if the prediction fails,CPU You need to roll back the previous instructions and load the correct instructions,To ensure the correctness of the program execution。
@@ -23,7 +24,6 @@ For the data of this question,character ‘a’ and ‘b’ It can be consider
23
24
24
25
Notice:This optimization method often reduces readability,It's best not to use in business code。
0 commit comments