mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update greedy_algorithms/jumpgame.cpp
Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>
This commit is contained in:
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user