points
to map numbers to their total points.nums
, maxNumber
.maxPoints(num)
that uses memoization to store results.maxPoints
, check if num
is in the memoization cache. If so, return the cached result.num
is not in the cache, compute maxPoints(num)
using the recurrence relation.maxPoints(maxNumber)
to get the maximum points and return it.