mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-12 23:15:52 +08:00
documentation updated final
This commit is contained in:
committed by
GitHub
parent
96882beeaa
commit
d948f89db9
@@ -1,9 +1,15 @@
|
||||
/**
|
||||
* @file
|
||||
* \brief Implementation of an algorithm to solve the jumping game problem
|
||||
* \details
|
||||
* @brief Implementation of an algorithm to solve the jumping game problem
|
||||
* @details
|
||||
* This algorithm is a greedy algorithm.
|
||||
* This solution takes in input as a vector and output as a boolean to check if you can reach the last position.
|
||||
* We name the indices good and bad based on whether we can reach the destination if we start at that position.
|
||||
* We initialize the last index as lastPos.
|
||||
* Here, we start from the end of the array and check if we can ever reach the first index.
|
||||
* We check if the sum of the index and the maximum jump count given is greater than or equal to the lastPos.
|
||||
* If yes, then that is the last position you can reach starting from the back.
|
||||
* After the end of the loop, if we reach the lastPos as 0, then the destination can be reached from the start position.
|
||||
* @author [Rakshaa Viswanathan](https://github.com/rakshaa2000)
|
||||
*/
|
||||
|
||||
@@ -11,14 +17,7 @@
|
||||
#include<iostream>
|
||||
#include <cassert>
|
||||
|
||||
//Implements the algorithm
|
||||
/*We name the indices good and bad based on whether we can reach the destination if we start at that position.
|
||||
*We initialize the last index as lastPos.
|
||||
*Here, we start from the end of the array and check if we can ever reach the first index.
|
||||
*We check if the sum of the index and the maximum jump count given is greater than or equal to the lastPos.
|
||||
*If yes, then that is the last position you can reach starting from the back.
|
||||
*After the end of the loop, if we reach the lastPos as 0, then the destination can be reached from the start position.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function implements the above algorithm
|
||||
* @param array of numbers containing the maximum jump (in steps) from that index
|
||||
|
||||
Reference in New Issue
Block a user