Skip to content

Commit 8ac210c

Browse files
authored
Update Solution.kt
1 parent 0344b04 commit 8ac210c

File tree

1 file changed

+2
-3
lines changed
  • src/main/kotlin/g0501_0600/s0546_remove_boxes

1 file changed

+2
-3
lines changed

src/main/kotlin/g0501_0600/s0546_remove_boxes/Solution.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package g0501_0600.s0546_remove_boxes
33
// #Hard #Array #Dynamic_Programming #Memoization
44
// #2023_01_17_Time_283_ms_(100.00%)_Space_46.9_MB_(100.00%)
55

6-
internal class Solution {
6+
@Suppress("NAME_SHADOWING")
7+
class Solution {
78
// dp for memoization
89
lateinit var dp: Array<Array<IntArray>>
910
fun removeBoxes(boxes: IntArray): Int {
@@ -30,12 +31,10 @@ internal class Solution {
3031
i++
3132
streak++
3233
}
33-
3434
// memoization
3535
if (dp[i][j][streak] > 0) {
3636
return dp[i][j][streak]
3737
}
38-
3938
// we calculate the ans here which is streak (length of similar elements) and move
4039
// forward to the remaining block through recursion
4140
var ans = (streak + 1) * (streak + 1) + get(boxes, i + 1, j, 0)

0 commit comments

Comments
 (0)