lastPos = nums.size() - 1;
44 for(
size_ti = lastPos; i !=
static_cast<size_t>(-1); i--) {
45 if(i + nums[i] >= lastPos) {
51}
// namespace greedy_algorithms 64std::cout <<
"All tests have successfully passed!\n";
72 test();
// run self-test implementationsstatic void test()
Function to test the above algorithm.
int main()
Main function.
bool can_jump(const std::vector< int > &nums)
Checks whether the given element (default is 1) can jump to the last index.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4