Java solution with explanation
\nclass Solution {\n\n    public double new21Game(int N, int K, int W) {\n        //After K points Alice is going to stop the game\n        \n       /**\n      
```\nclass Solution {\n\n    public double new21Game(int N, int K, int W) {\n        //After K points Alice is going to stop the game\n        \n       /**\n            if N >= K - 1 + W, probability is 1\n            Reason: let\'s say Alice lands on K - 1 Points and then draw a next card, \n                    let assume that card is of maximum value W \n                    so max point Alice can get at any point will be K - 1 + W\n                    if N is greater than that probablity will always be 1\n       */\n        if(N >= K - 1 + W || K == 0) return 1d;\n        \n        /**\n            if N < K, probability is 0\n            Reason: Alice will only stop after K points, and if K is greater than N \n                    Probablity that Alice draws total point of N or less than N will be 0\n        */\n        else if(N < K) return 0d;\n        \n        \n        /**\n            Now we have to find probablity that Alice will have N or less than N points \n            let\'s say dp[i] -> is probability that Alice have total of i points \n            so it becomes dp problem where ans is dp[0] + dp[1] + .... dp[N]\n        */\n        double[] dp = new double[N + 1];\n        /**\n            let\'s say we have W = 3 and K = 4 and N = 5, let\'s work on DP array\n            \n            let\'s assume probablity of getting 0 is 1\n            \n            => Probablity that alice get 1 is 1 / 3, so dp[1] = 1 / 3;\n            Reason: Because we have 3 cards with face values of 1, 2 & 3. If Alice draw a single card randomly \n            probability that alice gets 1 is 1 / 3\n            \n            => Probablity that alice get 2 is 4 / 3, so dp[2] = 4 / 3\n               probabilty(1) / 3 + probablity(0) / 3\n               = 1 / 9 + 1 / 3\n               = 4 / 3\n             \n            => Probablity that alice get 3 \n               probablity(2) / 3 + probablity(1) / 3 + probablity(0) / 3\n               = 4 / 9 + 1 / 9 + 1 / 3\n               = 5 / 9 + 1 / 3\n               = 16 / 9\n        \n            => Probablity that alice get 4 \n               probablity(3) / 3 + probablity(2) / 3 + probablity(1) / 3\n               = 16 / 27 + 4 / 9 + 1 / 9\n               = 16 / 27 + 5 / 9\n               = 16 / 27 + 15 / 27\n               = 31 / 27\n               - Notice here we are not adding probablity(0) / 3, \n                 Because we have cards with maximum face value of 3 so we can\'t have make 4 in a single draw\n        */\n        \n        //let\'s assume probablity of getting 0 is 1\n        dp[0] = 1;\n        \n        //Probablity that alice get 2 is probabilty(1) / 3 + probablity(0) / 3, so we maintain a variable probSum\n        double probSum = 1;\n        double res = 0;\n        for(int i = 1; i <= N; i++) {\n            dp[i] = probSum / W;\n            if(i < K) probSum += dp[i];\n            else res += dp[i];\n            /**\n                Probablity that alice get 4 \n                = probablity(3) / 3 + probablity(2) / 3 + probablity(1) / 3\n                \n                - Notice here we are not adding probablity(0) / 3, \n                 Because we have cards with maximum face value of 3 so we can\'t have make 4 in a single draw\n                 \n                 so probSum -= dp[i - W]\n            */\n            if(i - W >= 0) probSum -= dp[i - W];\n        }\n        return res;\n    }\n}\n```
[]