2024-02-05发表2024-02-05更新LeetCode每日一题几秒读完 (大约96个字)0次访问1696. 跳跃游戏 VI1696. 跳跃游戏 VI 难度: medium 原始链接: https://leetcode.cn/problems/jump-game-vi 标签: 单调栈 解法一: 单调栈go1234567891011121314151617func maxResult(nums []int, k int) int { n := len(nums) dp := make([]int, n) dp[0] = nums[0] stack := []int{0} for i := 1; i < n; i++ { if stack[0] < i-k { stack = stack[1:] } dp[i] = nums[i] + dp[stack[0]] for len(stack) > 0 && dp[stack[len(stack)-1]] <= dp[i] { stack = stack[:len(stack)-1] } stack = append(stack, i) } return dp[n-1]}1696. 跳跃游戏 VIhttps://wuhunyu.top/leetcode/2024/02/jump-game-vi/index.html作者wuhunyu发布于2024-02-05更新于2024-02-05许可协议#单调栈