Back to course home
0% completed
Vote For New Content
Recursive dp solution
Mohammed Dh Abbas
Oct 18, 2024
import math class Solution: def countMinJumps(self, jumps): def dp(index, count, memo): if (index, count) in memo: return memo[(index, count)] if index >= len(jumps) - 1: return count min_count = float('inf') for i in range(index + 1, index + jumps[index] + 1): min_count = min(dp(i, count + 1, memo), min_count) memo[(index, count)] = min_count return min_count return dp(0, 0, {})
0
0
Comments
Comments
On this page