File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 225
225
282|[ Expression Add Operators] ( ./0282-expression-add-operators.js ) |Hard|
226
226
283|[ Move Zeroes] ( ./0283-move-zeroes.js ) |Easy|
227
227
290|[ Word Pattern] ( ./0290-word-pattern.js ) |Easy|
228
+ 292|[ Nim Game] ( ./0292-nim-game.js ) |Easy|
228
229
295|[ Find Median from Data Stream] ( ./0295-find-median-from-data-stream.js ) |Hard|
229
230
303|[ Range Sum Query - Immutable] ( ./0303-range-sum-query-immutable.js ) |Easy|
230
231
316|[ Remove Duplicate Letters] ( ./0316-remove-duplicate-letters.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 292. Nim Game
3
+ * https://leetcode.com/problems/nim-game/
4
+ * Difficulty: Easy
5
+ *
6
+ * You are playing the following Nim Game with your friend:
7
+ * - Initially, there is a heap of stones on the table.
8
+ * - You and your friend will alternate taking turns, and you go first.
9
+ * - On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.
10
+ * - The one who removes the last stone is the winner.
11
+ *
12
+ * Given n, the number of stones in the heap, return true if you can win the game assuming
13
+ * both you and your friend play optimally, otherwise return false.
14
+ */
15
+
16
+ /**
17
+ * @param {number } n
18
+ * @return {boolean }
19
+ */
20
+ var canWinNim = function ( n ) {
21
+ return n % 4 !== 0 ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments