LeetCode 45

和跳跃游戏I差不多~
class Solution {
   
public:
    int jump(vector<int>& nums) {
   
        const int N=1e4+10;
        int dp[N]={
   0};
        for(int i=1;i<nums.size();i++)
        {
   
            dp[i]=0x3f3f3f3f;
        }
        //init操作
        for(int i=0;i<nums.size();i++)
        {
   
            for(int j=1;j<=nums[i];j++)
            {
   
                if(i+j<nums.size())
                {
   
                    dp[i+j]=min(dp[i+j],dp[i]+1);
                }
            }
        }
        return dp[nums.size()-1];
    }
};

相关推荐

  1. LeetCode 1193, 45, 48

    2024-01-05 17:28:01       32 阅读
  2. LeetCode 45

    2024-01-05 17:28:01       69 阅读
  3. LeetCode-45.跳跃游戏】

    2024-01-05 17:28:01       38 阅读
  4. leetcode40

    2024-01-05 17:28:01       36 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-05 17:28:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-05 17:28:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-05 17:28:01       82 阅读
  4. Python语言-面向对象

    2024-01-05 17:28:01       91 阅读

热门阅读

  1. UE5.1_Python使用1

    2024-01-05 17:28:01       42 阅读
  2. Linux测试硬盘的读取速度

    2024-01-05 17:28:01       54 阅读
  3. 选择 省市区 组件数据 基于vue3 + elment-plus

    2024-01-05 17:28:01       51 阅读
  4. blender Texture Coordinate Node

    2024-01-05 17:28:01       52 阅读
  5. C++ Optins接口封装设置自动重连

    2024-01-05 17:28:01       52 阅读
  6. ArrayList 与 LinkedList 的选择与应用

    2024-01-05 17:28:01       67 阅读
  7. c++,mutex,unique_lock,recursive_mutex,shared_mutex对比分析

    2024-01-05 17:28:01       46 阅读
  8. 【微服务】微服务详解、模块化开发详解

    2024-01-05 17:28:01       56 阅读
  9. MySQL运维实战(2.3)MySQL的权限体系

    2024-01-05 17:28:01       53 阅读
  10. Hbase 的三个应用

    2024-01-05 17:28:01       47 阅读
  11. 【React】04-关于React Props的实践

    2024-01-05 17:28:01       51 阅读
  12. 如何有效使用 .gitignore 文件

    2024-01-05 17:28:01       51 阅读