Skip to content

Commit 9492b7f

Browse files
committed
Add solution #877
1 parent 98e30c0 commit 9492b7f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@
684684
874|[Walking Robot Simulation](./0874-walking-robot-simulation.js)|Medium|
685685
875|[Koko Eating Bananas](./0875-koko-eating-bananas.js)|Medium|
686686
876|[Middle of the Linked List](./0876-middle-of-the-linked-list.js)|Easy|
687+
877|[Stone Game](./0877-stone-game.js)|Medium|
687688
884|[Uncommon Words from Two Sentences](./0884-uncommon-words-from-two-sentences.js)|Easy|
688689
889|[Construct Binary Tree from Preorder and Postorder Traversal](./0889-construct-binary-tree-from-preorder-and-postorder-traversal.js)|Medium|
689690
890|[Find and Replace Pattern](./0890-find-and-replace-pattern.js)|Medium|

solutions/0877-stone-game.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* 877. Stone Game
3+
* https://leetcode.com/problems/stone-game/
4+
* Difficulty: Medium
5+
*
6+
* Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a
7+
* row, and each pile has a positive integer number of stones piles[i].
8+
*
9+
* The objective of the game is to end with the most stones. The total number of stones across all
10+
* the piles is odd, so there are no ties.
11+
*
12+
* Alice and Bob take turns, with Alice starting first. Each turn, a player takes the entire pile
13+
* of stones either from the beginning or from the end of the row. This continues until there are
14+
* no more piles left, at which point the person with the most stones wins.
15+
*
16+
* Assuming Alice and Bob play optimally, return true if Alice wins the game, or false if Bob wins.
17+
*/
18+
19+
/**
20+
* @param {number[]} piles
21+
* @return {boolean}
22+
*/
23+
var stoneGame = function(piles) {
24+
return true;
25+
};

0 commit comments

Comments
 (0)