
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to find the minimum number of jumps required to reach the end of the array using C#?
We can simply start from the first element and repeatedly call for all the elements reachable from first element. The minimum number of jumps to reach end from first can be calculated using minimum number of jumps needed to reach end from the elements reachable from first.
Array == {1, 3, 6, 3, 2, 3, 6, 8, 9, 5};
Number of steps required is 4
Example
using System; namespace ConsoleApplication{ public class Arrays{ public int MinJumps(int[] arr, int l, int h){ if (h == l) return 0; if (arr[l] == 0) return int.MaxValue; int min = int.MaxValue; for (int i = l + 1; i <= h && i <= l + arr[l]; i++){ int jumps = MinJumps(arr, i, h); if (jumps != int.MaxValue && jumps + 1 < min) min = jumps + 1; } return min; } } class Program{ static void Main(string[] args){ Arrays a = new Arrays(); int[] arrm = { 1, 3, 6, 3, 2, 3, 6, 8, 9, 5 }; int n = arrm.Length; Console.Write(" Minimum number of jumps to reach end is " + a.MinJumps(arrm, 0, n - 1)); } } }
Output
4
- Related Articles
- C Program for Minimum number of jumps to reach the end
- Find minimum steps required to reach the end of a matrix in C++
- Program to find minimum number of hops required to reach end position in Python
- Find the minimum of maximum length of a jump required to reach the last island in exactly k jumps in Python
- Program to Find Minimum Jumps Required to Reach a Value with Different Parity in Python
- Program to find minimum jumps to reach home in Python
- Find the number of jumps to reach X in the number line from zero in C++
- How to find the minimum number of steps needed by knight to reach the destination using C#?
- Program to find minimum number of buses required to reach final target in python
- Minimum number of operations required to delete all elements of the array using C++.
- Maximum power of jump required to reach the end of string in C++
- Minimum Number of Jumps Problem
- Program to find minimum number of vertices to reach all nodes using Python
- Finding minimum number of required operations to reach n from m in JavaScript
- Minimum number of mails required to distribute all the questions using C++.

Advertisements