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/where_will_ball_fall.cpp | 50 ------------------------------------------ 1 file changed, 50 deletions(-) delete mode 100644 other/where_will_ball_fall.cpp (limited to 'other/where_will_ball_fall.cpp') diff --git a/other/where_will_ball_fall.cpp b/other/where_will_ball_fall.cpp deleted file mode 100644 index 4195778..0000000 --- a/other/where_will_ball_fall.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vector findBall(vvd & grid) { - int m = grid.size(), n = grid[0].size(); - vvd ugrid(m * 3, vector(n * 3)); - for (auto i = 0; i < m; i++) - for (auto j = 0; j < n; j++) { - ugrid[i * 3 + 1][j * 3 + 1] = 1; - ugrid[i * 3][j * 3] = ugrid[i * 3 + 2][j * 3 + 2] = grid[i][j] == 1; - ugrid[i * 3][j * 3 + 2] = ugrid[i * 3 + 2][j * 3] = grid[i][j] != 1; - } - vector ans; - for (auto i = 0; i < n; ++i) - ans.push_back(drop(i * 3 + 1, ugrid, m * 3, n * 3)); - return ans; - } - -private: - vector> dir{{1, 0}, {0, -1}, {0, 1}}; - int drop(int pos, vvd & ugrid, int m, int n) { - queue> qp; - qp.push({0, pos}); - while (!qp.empty()) { - auto [i, j] = qp.front(); - qp.pop(); - if (i == m - 1) - return j / 3; - ugrid[i][j] = 1; - for (auto [di, dj] : dir) - if (j + dj >= 0 && j + dj < n && !ugrid[i + di][j + dj]) { - qp.push({i + di, j + dj}); - break; - } - } - return -1; - } -}; - -int main() { - Solution obj; - vvd grid = {{1, 1, 1, -1, -1}, - {1, 1, 1, -1, -1}, - {-1, -1, -1, 1, 1}, - {1, 1, 1, 1, -1}, - {-1, -1, -1, -1, -1}}; - for (auto i : obj.findBall(grid)) - cout << i << ' '; -} -- cgit v1.2.3