Skip to content

Commit d26f450

Browse files
committed
feat(leetcode): solve 4136 - Concatenate Non Zero Digits And Multiply By Sum Ii
1 parent aec6275 commit d26f450

4 files changed

Lines changed: 60 additions & 22 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@ Automatically synchronize accepted LeetCode submissions to GitHub.
99
```text
1010
████████████░░░░░░░░░░░░░░░░░░
1111
12-
Solved: 126 / 300 Problems
12+
Solved: 127 / 300 Problems
1313
1414
📊 Statistics
1515
Difficulty Solved
1616
🟢 Easy 63
17-
🟡 Medium 57
17+
🟡 Medium 58
1818
🔴 Hard 6
19-
Total 126
19+
Total 127
2020
🔥 Latest Accepted Problem
2121
2222
2323
| Field | Value |
2424
|------|------|
25-
| Problem ID | 207 |
26-
| Title | Course Schedule |
25+
| Problem ID | 4136 |
26+
| Title | Concatenate Non Zero Digits And Multiply By Sum Ii |
2727
| Language | Python3 |
28-
| Runtime | 7 ms |
29-
| Memory | 21.7 MB |
28+
| Runtime | 361 ms |
29+
| Memory | 57.8 MB |
3030
3131
3232
💻 Languages Used
3333
34-
- **Python3** : 80
34+
- **Python3** : 81
3535
3636
## 📚 Recent Accepted Problems
3737
38+
- 4136 Concatenate Non Zero Digits And Multiply By Sum Ii
3839
- 207 Course Schedule
3940
- 1036 Rotting Oranges
4041
- 695 Max Area Of Island
4142
- 417 Pacific Atlantic Water Flow
42-
- 207 Course Schedule
4343
4444
4545
---
@@ -81,4 +81,4 @@ Git
8181
GitHub
8282
⏰ Last Sync
8383
84-
2026-07-08 14:04:58
84+
2026-07-09 09:38:36
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"submission_id": "2061160195",
3+
"question_id": "4136",
4+
"title_slug": "concatenate-non-zero-digits-and-multiply-by-sum-ii",
5+
"language": "python3",
6+
"language_verbose": "Python3",
7+
"runtime": "361 ms",
8+
"memory": "57.8 MB",
9+
"status_code": 10,
10+
"timestamp": 1783566675
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
MOD, MAX = 1000000007, 100001
2+
pow = [1] * MAX
3+
for i in range(1, MAX):
4+
pow[i] = (pow[i - 1] * 10) % MOD
5+
6+
class Solution:
7+
def sumAndMultiply(self, s: str, queries: list[list[int]]) -> list[int]:
8+
n, res = len(s), []
9+
A, B, Len = [[0] * (n + 1) for _ in range(3)]
10+
11+
for i in range(n):
12+
d = int(s[i])
13+
A[i + 1] = A[i] + d
14+
B[i + 1] = (B[i] * 10 + d) % MOD if d else B[i]
15+
Len[i + 1] = Len[i] + (d > 0)
16+
17+
res = []
18+
19+
for l, r in queries:
20+
r += 1
21+
22+
sub = (B[l] * pow[Len[r] - Len[l]]) % MOD
23+
x = (B[r] - sub) % MOD
24+
25+
res.append((x * (A[r] - A[l])) % MOD)
26+
27+
return res

storage/stats.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
2-
"total": 126,
2+
"total": 127,
33
"easy": 63,
4-
"medium": 57,
4+
"medium": 58,
55
"hard": 6,
66
"languages": {
7-
"Python3": 80
7+
"Python3": 81
88
},
99
"recent_problems": [
10+
{
11+
"id": "4136",
12+
"title": "Concatenate Non Zero Digits And Multiply By Sum Ii"
13+
},
1014
{
1115
"id": "207",
1216
"title": "Course Schedule"
@@ -22,18 +26,14 @@
2226
{
2327
"id": "417",
2428
"title": "Pacific Atlantic Water Flow"
25-
},
26-
{
27-
"id": "207",
28-
"title": "Course Schedule"
2929
}
3030
],
3131
"last_problem": {
32-
"id": "207",
33-
"title": "Course Schedule",
32+
"id": "4136",
33+
"title": "Concatenate Non Zero Digits And Multiply By Sum Ii",
3434
"language": "Python3",
35-
"runtime": "7 ms",
36-
"memory": "21.7 MB"
35+
"runtime": "361 ms",
36+
"memory": "57.8 MB"
3737
},
38-
"last_sync": "2026-07-08 14:04:58"
38+
"last_sync": "2026-07-09 09:38:36"
3939
}

0 commit comments

Comments
 (0)