Leetcode-cn.com 2022-05-22
🟡 464.can-i-win
🏷️ Tags
#bit_manipulation #memoization #math #dynamic_programming #bitmask #game_theory
Description
在 "100 game" 这个游戏中,两名玩家轮流选择从
如果我们将游戏规则改为 “玩家 不能 重复使用整数” 呢?
例如,两个玩家可以轮流从公共整数池中抽取从 1 到 15 的整数(不放回),直到累计整数和 >= 100。
给定两个整数
Example
🟡 464.can-i-win
🏷️ Tags
#bit_manipulation #memoization #math #dynamic_programming #bitmask #game_theory
Description
在 "100 game" 这个游戏中,两名玩家轮流选择从
1 到 10 的任意整数,累计整数和,先使得累计整数和 达到或超过 100 的玩家,即为胜者。如果我们将游戏规则改为 “玩家 不能 重复使用整数” 呢?
例如,两个玩家可以轮流从公共整数池中抽取从 1 到 15 的整数(不放回),直到累计整数和 >= 100。
给定两个整数
maxChoosableInteger (整数池中可选择的最大数)和 desiredTotal(累计和),若先出手的玩家是否能稳赢则返回 true ,否则返回 false 。假设两位玩家游戏时都表现 最佳 。Example
输入:maxChoosableInteger = 10, desiredTotal = 11
输出:false
解释:
无论第一个玩家选择哪个整数,他都会失败。
第一个玩家可以选择从 1 到 10 的整数。
如果第一个玩家选择 1,那么第二个玩家只能选择从 2 到 10 的整数。
第二个玩家可以通过选择整数 10(那么累积和为 11 >= desiredTotal),从而取得胜利.
同样地,第一个玩家选择任意其他整数,第二个玩家都会赢。
leetcode.com 2023-07-28
🟡486.predict-the-winner
🏷️ Tags
#recursion #array #math #dynamic_programming #game_theory
🟡486.predict-the-winner
🏷️ Tags
#recursion #array #math #dynamic_programming #game_theory
Telegraph
predict-the-winner
You are given an integer array nums. Two players are playing a game with this array: player 1 and player 2. Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of 0. At each turn, the player takes one of…
leetcode.com 2023-10-02
🟡2038.remove-colored-pieces-if-both-neighbors-are-the-same-color
🏷️ Tags
#greedy #math #string #game_theory
🟡2038.remove-colored-pieces-if-both-neighbors-are-the-same-color
🏷️ Tags
#greedy #math #string #game_theory
Telegraph
remove-colored-pieces-if-both-neighbors-are-the-same-color
There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and Bob are playing a game where they take alternating turns removing…
leetcode.com 2023-11-24
🟡1561.maximum-number-of-coins-you-can-get
🏷️ Tags
#greedy #array #math #game_theory #sorting
🟡1561.maximum-number-of-coins-you-can-get
🏷️ Tags
#greedy #array #math #game_theory #sorting
Telegraph
maximum-number-of-coins-you-can-get
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
leetcode.cn 2024-02-02
🟡1686.stone-game-vi
🏷️ Tags
#greedy #array #math #game_theory #sorting #heap_priority_queue
🟡1686.stone-game-vi
🏷️ Tags
#greedy #array #math #game_theory #sorting #heap_priority_queue
Telegraph
stone-game-vi
Alice 和 Bob 轮流玩一个游戏,Alice 先手。 一堆石子里总共有 n 个石子,轮到某个玩家时,他可以 移出 一个石子并得到这个石子的价值。Alice 和 Bob 对石子价值有 不一样的的评判标准 。双方都知道对方的评判标准。 给你两个长度为 n 的整数数组 aliceValues 和 bobValues 。aliceValues[i] 和 bobValues[i] 分别表示 Alice 和 Bob 认为第 i 个石子的价值。 所有石子都被取完后,得分较高的人为胜者。如果两个玩家得分相同,那么为平局。两位玩家都会采用…