837. New 21 Game, Daily LeetCoding Challenge
\nclass Solution {\npublic:\n    double new21Game(int n, int k, int maxPts) {\n        if (k==0 || n>=k+maxPts) return 1.0;\n      vector<double>dp(n+1,0);\n   
```\nclass Solution {\npublic:\n    double new21Game(int n, int k, int maxPts) {\n        if (k==0 || n>=k+maxPts) return 1.0;\n      vector<double>dp(n+1,0);\n      dp[0]=1.0;\n      double result=0;\n      double runningSum=dp[0];\n      for (int i=1;i<=n;i++)\n      {\n          dp[i]=runningSum/(double)maxPts;\n          if (i<k)\n          {\n              runningSum+=dp[i];\n          }\n          else{\n              result+=dp[i];\n          }\n          if (i-maxPts>=0)\n          runningSum-=dp[i-maxPts];\n      }\n      return result;\n\n    }\n};\n```
[]