Daily Problem
Diffstat:
2 files changed, 18 insertions(+), 0 deletions(-)
@@ -0,0 +1,17 @@
class Solution {
public:
double new21Game(int n, int k, int maxPts) {
if (k == 0 || n >= k + maxPts) return 1.0;
vector<double> dp(n + 1);
double sum = 1.0, ans = 0.0;
dp[0] = 1.0;
for (int i = 1; i < n + 1; i++) {
dp[i] = sum / maxPts;
(i < k ? sum : ans) += dp[i];
if (i - maxPts >= 0) sum -= dp[i - maxPts];
}
return ans;
}
};
@@ -346,6 +346,7 @@
for solving problems.
| 0802 | Medium | [Find Eventual Safe States](Problems/0802.cpp) |
| 0815 | Hard | [Bus Routes](Problems/0815.cpp) |
| 0830 | Medium | [Kth Smallest Element in a BST](Problems/0230.cpp) |
| 0837 | Medium | [New 21 Game](Problems/0837.cpp) |
| 0839 | Hard | [Similar String Groups](Problems/0839.cpp) |
| 0841 | Medium | [Keys and Rooms](Problems/0841.cpp) |
| 0844 | Easy | [Backspace String Compare](Problems/0844.cpp) |