C# using DP + sliding window
Approach\n- To calculate the probability of winning, we can use DP (dynamic programming) to keep track of the probabilities for each point.\n- Use sliding windo
# Approach\n- To calculate the probability of winning, we can use DP (dynamic programming) to keep track of the probabilities for each point.\n- Use sliding window `windowSum` to efficiently calculate probabilities.\n- Calculate the probabilities. `dp[0]` is `1.0`. For each point `i` ($$1..n$$), the probability of reaching that point is the sum of probabilities from the previous `maxPts` points divided by `maxPts`.\n- If `i` is less than `k`, we add the probability to the `windowSum` to keep sum of previous probabilities.\n- If `i` is `>= k`, we add the probability to `probability` variable.\n\n# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```\npublic class Solution\n{\n    public double New21Game(int n, int k, int maxPts)\n    {\n        if (k == 0 || n >= k + maxPts)\n        {\n            return 1.0;\n        }\n\n        var windowSum = 1.0;\n        var probability = 0.0;\n\n        var dp = new double[n + 1];\n        dp[0] = 1.0;\n\n        for (var i = 1; i <= n; i++)\n        {\n            dp[i] = windowSum / maxPts;\n\n            if (i < k)\n            {\n                windowSum += dp[i];\n            }\n            else\n            {\n                probability += dp[i];\n            }\n\n            if (i >= maxPts)\n            {\n                windowSum -= dp[i - maxPts];\n            }\n        }\n\n        return probability;\n    }\n}\n```
['C#']