Skip to content

Commit 860ee81

Browse files
🥌 Day 25
1 parent 7d1bd16 commit 860ee81

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
1. [Minimum Depth of Binary Tree](https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3504/) ➡️ [CPP Solution](Week4/minDepth.cpp)
4141
2. [132 Pattern](https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3505/) ➡️ [CPP Solution](Week4/find132pattern.cpp)
4242
3. [Bag of Tokens](https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3506/) ➡️ [CPP Solution](Week4/bagOfTokensScore.cpp)
43+
4. [Stone Game IV](https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/562/week-4-october-22nd-october-28th/3507/) ➡️ [CPP Solution](Week4/winnerSquareGame.cpp)
4344

4445
## Week 5 🚧
4546

Week4/winnerSquareGame.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
bool winnerSquareGame(int n) {
4+
vector<bool> dp(n + 1, false);
5+
6+
for(int i = 1; i <= n; ++i) {
7+
for(int j = 1; j * j <= i; ++j) {
8+
if(!dp[i - j * j]) {
9+
dp[i] = true;
10+
break;
11+
}
12+
}
13+
}
14+
15+
return dp[n];
16+
}
17+
};

0 commit comments

Comments
 (0)