Skip to content

Commit 918ed38

Browse files
authored
feat: update solutions to lc problems: No.3661,3418 (#5129)
1 parent e9cfab5 commit 918ed38

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

solution/3400-3499/3418.Maximum Amount of Money Robot Can Earn/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ class Solution:
124124
return ans
125125

126126
m, n = len(coins), len(coins[0])
127-
return dfs(0, 0, 2)
127+
ans = dfs(0, 0, 2)
128+
dfs.cache_clear()
129+
return ans
128130
```
129131

130132
#### Java

solution/3400-3499/3418.Maximum Amount of Money Robot Can Earn/README_EN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ class Solution:
122122
return ans
123123

124124
m, n = len(coins), len(coins[0])
125-
return dfs(0, 0, 2)
125+
ans = dfs(0, 0, 2)
126+
dfs.cache_clear()
127+
return ans
126128
```
127129

128130
#### Java

solution/3400-3499/3418.Maximum Amount of Money Robot Can Earn/Solution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ def dfs(i: int, j: int, k: int) -> int:
1212
return ans
1313

1414
m, n = len(coins), len(coins[0])
15-
return dfs(0, 0, 2)
15+
ans = dfs(0, 0, 2)
16+
dfs.cache_clear()
17+
return ans

solution/3600-3699/3661.Maximum Walls Destroyed by Robots/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class Solution:
158158
ans = max(ans, dfs(i - 1, 1) + r - l)
159159
return ans
160160

161-
return dfs(n - 1, 1)
161+
ans = dfs(n - 1, 1)
162+
dfs.cache_clear()
163+
return ans
162164
```
163165

164166
#### Java

solution/3600-3699/3661.Maximum Walls Destroyed by Robots/README_EN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class Solution:
157157
ans = max(ans, dfs(i - 1, 1) + r - l)
158158
return ans
159159

160-
return dfs(n - 1, 1)
160+
ans = dfs(n - 1, 1)
161+
dfs.cache_clear()
162+
return ans
161163
```
162164

163165
#### Java

solution/3600-3699/3661.Maximum Walls Destroyed by Robots/Solution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ def dfs(i: int, j: int) -> int:
2525
ans = max(ans, dfs(i - 1, 1) + r - l)
2626
return ans
2727

28-
return dfs(n - 1, 1)
28+
ans = dfs(n - 1, 1)
29+
dfs.cache_clear()
30+
return ans

0 commit comments

Comments
 (0)