mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-12 23:15:52 +08:00
Update greedy_algorithms/jumpgame.cpp
Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4aea8495d6
commit
5e30e7eb64
@@ -23,7 +23,7 @@
|
||||
* @param array of numbers containing the maximum jump (in steps) from that index
|
||||
* @returns bool value whether final index can be reached or not
|
||||
*/
|
||||
bool canJump(std::vector<int> nums) {
|
||||
bool canJump(const std::vector<int> &nums) {
|
||||
auto lastPos = nums.size() - 1;
|
||||
for (auto i = nums.size() - 1; i >= 0; i--) {
|
||||
if (i + nums[i] >= lastPos) {
|
||||
|
||||
Reference in New Issue
Block a user