1
1
---
2
- id : minimum number of jumps
2
+ id : minimum- number-of- jumps
3
3
title : Minimum number of jumps
4
4
sidebar_label : 0022 Minimum number of jumps
5
5
tags :
@@ -40,7 +40,6 @@ The brute force approach involves recursively checking all possible jumps from e
40
40
The implementation recursively checks all possible jumps from each element, updating the minimum number of jumps needed.
41
41
42
42
``` cpp
43
- // C++ Implementation
44
43
class Solution {
45
44
public:
46
45
int minimumJumps(int arr[ ] , int n) {
@@ -71,7 +70,6 @@ In this approach, we use dynamic programming to store the minimum number of jump
71
70
The code initializes an array to store the minimum jumps required and iterates through the array to calculate the minimum jumps.
72
71
73
72
``` cpp
74
- // C++ Implementation
75
73
class Solution {
76
74
public:
77
75
int minimumJumps(int arr[ ] , int n) {
@@ -97,7 +95,6 @@ public:
97
95
#### Python Implementation
98
96
99
97
``` python
100
- # Python Implementation
101
98
class Solution :
102
99
def minJumps (self , arr , n ):
103
100
if len (arr) <= 1 :
@@ -146,7 +143,6 @@ class Solution:
146
143
#### Java Implementation
147
144
148
145
``` java
149
- // Java Implementation
150
146
class Solution {
151
147
static int minJumps (int arr [])
152
148
{
@@ -209,7 +205,6 @@ This approach involves maintaining the maximum reachable index from the current
209
205
The implementation traverses the array, updating the maximum reachable index and the number of steps at each iteration.
210
206
211
207
``` cpp
212
- // C++ Implementation
213
208
class Solution {
214
209
public:
215
210
int minJumps(int arr[ ] , int n) {
@@ -242,7 +237,6 @@ public:
242
237
#### Python Implementation
243
238
244
239
``` python
245
- # Python Implementation
246
240
class Solution :
247
241
def minJumps (self , arr , n ):
248
242
if len (arr) <= 1 :
@@ -291,7 +285,6 @@ class Solution:
291
285
#### Java Implementation
292
286
293
287
``` java
294
- // Java Implementation
295
288
class Solution {
296
289
static int minJumps (int arr [])
297
290
{
0 commit comments