[Java] ✅ All Jump Game Solutions
https://leetcode.com/problems/jump-game/\n55. Jump Game: TC: / SC: O(n) / O(1)\n\n    public boolean canJump(int[] nums) {\n        int max_reach = 0;\n        
https://leetcode.com/problems/jump-game/\n**55. Jump Game: `TC: / SC: O(n) / O(1)`**\n```\n    public boolean canJump(int[] nums) {\n        int max_reach = 0;\n        \n        for(int i =0; i < nums.length; i++) {\n            if(i > max_reach) return false;\n            \n            max_reach = Math.max(max_reach, i + nums[i]);\n        }\n        \n        return true;\n    }\n```\nhttps://leetcode.com/problems/jump-game-ii/\n**45. Jump Game II: `TC: / SC: O(n) / O(1)`**\n```\n    public int jump(int[] nums) {\n        if(nums.length == 1) return 0;\n        \n        int temp = 0, max = 0, count = 0;\n        \n        for(int i = 0; i < nums.length; i++) {\n            if(i > temp) {\n                temp = max;\n                max = 0;\n                count++;\n            }\n            max = Math.max(max, nums[i] + i);\n        }\n        \n        return count;\n    }\n```\nhttps://leetcode.com/problems/jump-game-iii/\n**1306. Jump Game III: `TC: / SC: O(n) / O(n)`**\n```\n    public static boolean[] jumped;\n    public boolean canReach(int[] arr, int start) {\n        jumped = new boolean[arr.length];\n        \n        return check(arr, start);\n    }\n    public boolean check(int[] arr, int i) {\n        if(i >= arr.length || i < 0 || jumped[i]) return false;\n        if(arr[i] == 0) return true;\n        jumped[i] = true;\n        \n        return check(arr, i + arr[i]) || check(arr, i - arr[i]);\n    }\n```\nhttps://leetcode.com/problems/jump-game-iv/\n**1345. Jump Game IV: `TC: / SC: O(n) / O(n)`**\n```\n    public int minJumps(int[] arr) {\n        int steps = 0;\n        HashMap<Integer, List<Integer>> map = new HashMap<>();\n        \n        for(int i = 0; i < arr.length; i++) \n            map.computeIfAbsent(arr[i], li -> new ArrayList()).add(i);\n        \n        boolean[] jumped = new boolean[arr.length]; \n        jumped[0] = true;\n        Queue<Integer> q = new LinkedList<>(); \n        q.offer(0);\n        \n        while(!q.isEmpty()) {\n            for(int i = q.size(); i > 0; i--) {\n                int temp = q.poll();\n                if(temp == arr.length - 1) return steps;\n                \n                List<Integer> li = map.get(arr[temp]);\n                if(temp != 0) li.add(temp - 1);\n                if(temp != arr.length) li.add(temp + 1);\n                \n                for(int j : li) {\n                    if(!jumped[j]) {\n                        jumped[j] = true;\n                        q.offer(j);\n                    }\n                }\n                li.clear();\n            }\n            steps++;\n        }\n        \n        return 0;\n    }\n```\nhttps://leetcode.com/problems/jump-game-vi/submissions/\n**1696. Jump Game VI: `TC: / SC: O(n) / O(n)`**\n```\n    public int maxResult(int[] nums, int k) {\n        Deque<Integer> dq = new ArrayDeque<>();\n        dq.offer(0);\n        \n        for(int i = 1; i < nums.length; i++) {\n            nums[i] += nums[dq.peekFirst()];\n            \n            while(!dq.isEmpty() && nums[dq.peekLast()] <= nums[i])\n                dq.pollLast();\n            dq.offer(i);\n            \n            if(i - dq.peekFirst() >= k) dq.pollFirst();\n        } \n        \n        return nums[nums.length - 1];\n    }\n```\nhttps://leetcode.com/problems/jump-game-vii/submissions/\n\u2705**1871. Jump Game VII: `TC: / SC: O(n) / O(n)`**\n```\n    public boolean canReach(String s, int minJump, int maxJump) {\n        int n = s.length(), available = 0;\n        if(s.charAt(n - 1) == \'1\') return false;\n        \n        boolean[] dp = new boolean[n];\n        dp[0] = true;\n        \n        for(int i = 1; i < n; i++) {\n            if(i >= minJump) available += dp[i - minJump] ? 1 : 0;\n            if(i > maxJump) available -= dp[i - maxJump - 1] ? 1 : 0;\n            \n            dp[i] = available > 0 && s.charAt(i) == \'0\';\n        }\n        \n        return dp[n - 1];\n    }\n```
['Dynamic Programming', 'Breadth-First Search', 'Java']