103 - Jump Game II - Final DP solution in Java

Pseudo code: // int[] nums int level = 0, left = 0, right = 0; while (right is less than ( - 1)) { int farthest = 0; for (int i = left; i is less than or equal to right; i ) { farthest = MAX(farthest, i nums[i]); } left = right 1; right = farthest; level ; } return level; Time complexity: O(n) Space complexity: O(1) Leetcode: Github:
Back to Top