package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
45. Jump Game II
Solution idea
My solution - DP
Define $DP[i]$ as minimun jumps from index $0$ to index $i$.
Base case:
$DP[0] = 0$ as need $0$ jumps at index $0$.
Recurrence:
$DP[i] = \min(DP[j])$ for $0 \leq j < i$ and $nums[j] \geq i-j$ (i.e. look at all $j$'s who can reach $i$)
Time Complexity = $O(n^2)$