2
var winnerSquareGame = function (n) {3
// //////////////////////////////////4
// 1. Define an array that Alice will win or loss (T/F)5
// //////////////////////////////////7
const res = new Array(n + 1).fill(false);10
for (let i = 1; i <= n; i++) {11
// //////////////////////////////////12
// 2. if it is square number, obviously, Alice win13
// //////////////////////////////////21
// //////////////////////////////////22
// 3. after Alice removes j*j (1 <= j < k) stones, find whether res[i-j*j] is T/F (= Bob win/loss)23
// if j exists that res[i-j*j] = false, it means that Bob will lose the game with the remaining i-j*j stones => Alice wins24
// otherwise, Alice lose25
// //////////////////////////////////28
for (let j = 1; j < k && j * j <= i; j++) {29
if (!res[i - j * j]) {