837. New 21 Game || Java
\nclass Solution {\n    public double new21Game(int n, int k, int maxPts) {\n        if(k==0||n>=k+maxPts)\n            return 1;\n        double dp[]=new doubl
```\nclass Solution {\n    public double new21Game(int n, int k, int maxPts) {\n        if(k==0||n>=k+maxPts)\n            return 1;\n        double dp[]=new double[n+1];\n        Arrays.fill(dp,0.0);\n        dp[0]=1;\n        double cur_sum=dp[0];\n        for(int i=1;i<=n;i++)\n        {\n            dp[i]=cur_sum/(double)maxPts;\n            if(i<k)\n                cur_sum+=dp[i];\n            if(i>=maxPts)\n                cur_sum-=dp[i-maxPts];\n        }\n        double ans=0;\n        for(int i=k;i<=n;i++)\n            ans+=dp[i];\n        return ans;\n    }\n}\n```
[]