Solution in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    double new21Game(int n, int k, int maxPts) \n    {\n        if (k == 0 || n >= k + maxPts - 1) return 1.0;\n        vector<double> dp(n + 1);\n        dp[0] = 1.0;\n        double W = 1.0, res = 0.0;\n        for (int i = 1; i <= n; ++i) \n        {\n            dp[i] = W / maxPts;\n            if (i < k) W += dp[i];\n            else res += dp[i];\n            if (i - maxPts >= 0) W -= dp[i - maxPts];\n        }\n        return res;\n    }\n};\n```
['C++']