From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/knight_probability_chessboard.cpp | 41 --------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 other/knight_probability_chessboard.cpp (limited to 'other/knight_probability_chessboard.cpp') diff --git a/other/knight_probability_chessboard.cpp b/other/knight_probability_chessboard.cpp deleted file mode 100644 index 0c5094d..0000000 --- a/other/knight_probability_chessboard.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// 688. Knight Probability in Chessboard -#include "leetcode.h" - -/* - * on an 'n x n' chessboard, a knight starts at the cell '(row, column)' and - * attempts to make exactly 'k' moves. the rows and columns are 0-indexed, so - * the top-left cell is '(0, 0)', and the bottom-right cell is '(n - 1, n - 1)'. - * a chess knight has eight possible moves it can make, as illustrated below - * [see image]. each move is two cells in a cardinal direction, then one cell in - * an orthogonal direction. - */ - -class Solution { -public: - double knightProbability(int n, int k, int row, int col) { - unordered_map>> dp; - if (dp.count(row) && dp[row].count(col) && dp[row][row].count(k)) - return dp[row][col][k]; - if (row < 0 || row >= n || col < 0 || col >= n) - return 0; - if (!k) - return 1; - double total = knightProbability(n, k - 1, row - 1, col - 2) + - knightProbability(n, k - 1, row - 2, col - 1) + - knightProbability(n, k - 1, row - 1, col + 2) + - knightProbability(n, k - 1, row - 2, col + 1) + - knightProbability(n, k - 1, row + 1, col + 2) + - knightProbability(n, k - 1, row + 2, col + 1) + - knightProbability(n, k - 1, row + 1, col - 2) + - knightProbability(n, k - 1, row + 2, col - 1); - double ans = total / 8; - dp[row][col][k] = ans; - return ans; - } -}; - -int main() { - Solution obj; - printf("%f\n", obj.knightProbability(3, 2, 0, 0)); // expect: 0.06250 - printf("%f\n", obj.knightProbability(1, 0, 0, 0)); // expect: 1.00000 -} -- cgit v1.2.3