File tree 1 file changed +3
-3
lines changed
src/main/kotlin/g3401_3500/s3441_minimum_cost_good_caption
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ class Solution {
13
13
return " "
14
14
}
15
15
val arr = caption.toCharArray()
16
- val prefixCost = Array <IntArray ? >(n + 1 ) { IntArray (26 ) }
16
+ val prefixCost = Array <IntArray >(n + 1 ) { IntArray (26 ) }
17
17
for (i in 0 .. < n) {
18
18
val orig = arr[i].code - ' a' .code
19
19
for (c in 0 .. 25 ) {
20
- prefixCost[i + 1 ]!! [c] = prefixCost[i]!! [c] + abs((orig - c))
20
+ prefixCost[i + 1 ][c] = prefixCost[i][c] + abs((orig - c))
21
21
}
22
22
}
23
23
val dp = IntArray (n + 1 )
@@ -37,7 +37,7 @@ class Solution {
37
37
var bestLetter = 0
38
38
var bestCost: Int = INF
39
39
for (c in 0 .. 25 ) {
40
- val costBlock = prefixCost[i + l]!! [c] - prefixCost[i]!! [c]
40
+ val costBlock = prefixCost[i + l][c] - prefixCost[i][c]
41
41
if (costBlock < bestCost) {
42
42
bestCost = costBlock
43
43
bestLetter = c
You can’t perform that action at this time.
0 commit comments