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/3401-3500/3461.Check-If-Digits-Are-Equal-in-String-After-Operations-I/README.md
+35-13Lines changed: 35 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,50 @@
1
1
# [3461.Check If Digits Are Equal in String After Operations I][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` consisting of digits. Perform the following operation repeatedly until the string has **exactly** two digits:
5
+
6
+
- For each pair of consecutive digits in `s`, starting from the first digit, calculate a new digit as the sum of the two digits **modulo** 10.
7
+
- Replace `s` with the sequence of newly calculated digits, maintaining the order in which they are computed.
8
+
9
+
Return `true` if the final two digits in `s` are the **same**; otherwise, return `false`.
7
10
8
11
**Example 1:**
9
12
10
13
```
11
-
Input: a = "11", b = "1"
12
-
Output: "100"
14
+
Input: s = "3902"
15
+
16
+
Output: true
17
+
18
+
Explanation:
19
+
20
+
Initially, s = "3902"
21
+
First operation:
22
+
(s[0] + s[1]) % 10 = (3 + 9) % 10 = 2
23
+
(s[1] + s[2]) % 10 = (9 + 0) % 10 = 9
24
+
(s[2] + s[3]) % 10 = (0 + 2) % 10 = 2
25
+
s becomes "292"
26
+
Second operation:
27
+
(s[0] + s[1]) % 10 = (2 + 9) % 10 = 1
28
+
(s[1] + s[2]) % 10 = (9 + 2) % 10 = 1
29
+
s becomes "11"
30
+
Since the digits in "11" are the same, the output is true.
13
31
```
14
32
15
-
## 题意
16
-
> ...
17
-
18
-
## 题解
33
+
**Example 2:**
19
34
20
-
### 思路1
21
-
> ...
22
-
Check If Digits Are Equal in String After Operations I
0 commit comments