diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/where_will_ball_fall.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/where_will_ball_fall.cpp')
-rw-r--r-- | other/where_will_ball_fall.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
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<int> findBall(vvd & grid) { - int m = grid.size(), n = grid[0].size(); - vvd ugrid(m * 3, vector<int>(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<int> ans; - for (auto i = 0; i < n; ++i) - ans.push_back(drop(i * 3 + 1, ugrid, m * 3, n * 3)); - return ans; - } - -private: - vector<pair<int, int>> dir{{1, 0}, {0, -1}, {0, 1}}; - int drop(int pos, vvd & ugrid, int m, int n) { - queue<pair<int, int>> 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 << ' '; -} |