LeetCode每日一题(1690. Stone Game VII)

这篇博客详细介绍了LeetCode中的第1690题,即“石头游戏VII”。在这个游戏中,Alice和Bob轮流从一排石头中移除最左边或最右边的石头,并根据剩余石头的值之和得分。文章讨论了Bob总是会输的情况以及他如何尽量减少分数差距,而Alice的目标则是最大化这个差距。博主通过例子和代码(Rust语言)解析了动态规划解决方案,特别是如何理解dp状态转移方程的逻辑。
摘要由CSDN通过智能技术生成

Alice and Bob take turns playing a game, with Alice starting first.

There are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the higher score when there are no stones left to remove.

Bob found that he will always lose this game (poor Bob, he always loses), so he decided to minimize the score's difference. Alice's goal is to maximize the difference in the score.

Given an array of integers stones where stones[i] represents the value of the ith stone from the left, return the difference in Alice and Bob's score if they both play optimally.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值