Maximum Number of Points with Cost LeetCode solution in Python

1
class Solution:
2
def maxPoints(self, points: List[List[int]]) -> int:
3
m, n = len(points), len(points[0])
4

5
for i in range(m - 1):
6
for j in range(1, n):
7
points[i][j] = max(points[i][j], points[i][j - 1] - 1)
8

9
for j in range(n - 2, -1, -1):
10
points[i][j] = max(points[i][j], points[i][j + 1] - 1)
11

12
for j in range(n):
13
points[i + 1][j] += points[i][j]
14

15
return max(points[m - 1])

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0