File tree Expand file tree Collapse file tree
solutions/4136_Concatenate_Non_Zero_Digits_And_Multiply_By_Sum_Ii Expand file tree Collapse file tree Original file line number Diff line number Diff 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
1515Difficulty 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---
8181GitHub
8282⏰ Last Sync
8383
84- 2026-07-08 14:04:58
84+ 2026-07-09 09:38:36
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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"
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}
You can’t perform that action at this time.
0 commit comments