877. Stone Game
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 11, 2024
Last updated : July 11, 2024
Related Topics : Array, Math, Dynamic Programming, Game Theory
Acceptance Rate : 71.43 %
class Solution:
def stoneGame(self, piles: List[int]) -> bool:
pilesDq = deque(piles)
alice, bob = 0, 0
who = True
while pilesDq :
maxx = 0
if pilesDq[0] > pilesDq[-1] :
maxx = pilesDq.popleft()
else :
maxx = pilesDq.pop()
if who :
alice += maxx
else :
bob += maxx
return alice > bob
class Solution:
def stoneGame(self, piles: List[int]) -> bool:
return True
bool stoneGame(int* piles, int pilesSize) {
return true;
}
class Solution {
public:
bool stoneGame(vector<int>& piles) {
return true;
}
};
func stoneGame(piles []int) bool {
return true;
}
class Solution {
public boolean stoneGame(int[] piles) {
return true;
}
}
/**
* @param {number[]} piles
* @return {boolean}
*/
var stoneGame = function(piles) {
return true;
};