dp 编程

您所在的位置:网站首页 编程dp是什么 dp 编程

dp 编程

2024-05-24 04:24| 来源: 网络整理| 查看: 265

dp 编程

Problem: You are given an array of integers of length N in which value of each index represents maximum jump u can take from that index. You have to find minimum jumps required to reach from 0th index to the end of the array(last index).

问题:给您一个长度为N的整数数组,其中每个索引的值表示u从该索引可以进行的最大跳跃。 您必须找到从第0个索引到数组末尾(最后一个索引)所需的最小跳转。

Constraints:

限制条件:

1 // taking minimum of all possible jumps as ith index of // dp matrix represent minmum jumps required to reach from ith // index to the end if(min > dp[i+j]){ min = dp[i+j]; } } // also have to add 1 as 1 jump is required to jump on any // index in jump_range and storing that value dp[i] = 1 + min; } // return the minimum jumps from 0th index to the end return dp[0]; } // driver function to check the code int main() { int n; cout n; int arr[n] = {0}; cout cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3