Any help with this algorithm please?
My idea is as the below code speaks, it passed 11/21 test cases.\nI couldn't wrack my brain out of this what could be the bug/flaw of this algorithm.\nAny 2nd e
My idea is as the below code speaks, it passed 11/21 test cases.\nI couldn't wrack my brain out of this what could be the bug/flaw of this algorithm.\nAny 2nd eye look would be greatly appreciated!\n\n```\npublic double knightProbability(int N, int K, int r, int c) {\n            int[][] directions = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\n            Queue<int[]> queue = new LinkedList<>();\n            queue.offer(new int[]{r, c});\n            double prob = 1.0;\n            while (!queue.isEmpty() && K-- > 0) {\n                int[] curr = queue.poll();\n                int[] positive = new int[1];\n                for (int i = 0; i < directions.length; i++) {\n                    int[] direction = directions[i];\n                    int x = curr[0] + direction[0];\n                    int y = curr[1] + direction[1];\n                    check(N, queue, positive, x, y);\n                }\n                prob *= (double) positive[0] / 8;\n            }\n            return prob;\n        }\n\n        private void check(int N, Queue<int[]> queue, int[] positive, int x, int y) {\n            if (x >= 0 && x < N && y >= 0 && y < N) {\n                queue.offer(new int[]{x, y});\n                positive[0]++;\n            }\n        }\n```
[]