aboutsummaryrefslogtreecommitdiff
path: root/longest_increasing_matrix_path.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-02-03 15:37:19 -0700
committerJack Sangdahl <[email protected]>2025-02-03 15:37:19 -0700
commit55a67f776dd9acd258cae16ffb636751666b0f40 (patch)
tree601539de43809b70ceb8228a12c35883fa300b03 /longest_increasing_matrix_path.cpp
parenta0030873dabb517594ae0394350d6715071f7fb8 (diff)
downloadleetcode-55a67f776dd9acd258cae16ffb636751666b0f40.tar.gz
leetcode-55a67f776dd9acd258cae16ffb636751666b0f40.zip
chore: Remove incomplete solutions
Diffstat (limited to 'longest_increasing_matrix_path.cpp')
-rw-r--r--longest_increasing_matrix_path.cpp32
1 files changed, 0 insertions, 32 deletions
diff --git a/longest_increasing_matrix_path.cpp b/longest_increasing_matrix_path.cpp
deleted file mode 100644
index 1ee5b99..0000000
--- a/longest_increasing_matrix_path.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- int longestIncreasingPath(vector<vector<int>> &matrix) {
- int rows = matrix.size(), cols = matrix[0].size();
- if (!rows)
- return 0;
- vector<vector<int>> dp(rows, vector<int>(cols, 0));
- function<int(int, int)> dfs = [&](int x, int y) {
- if (dp[x][y])
- return dp[x][y];
- vector<vector<int>> dirs = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
- for (auto &dir : dirs) {
- int x2 = x + dir[0], y2 = y + dir[1];
- if (x2 < 0 || x2 >= rows || y2 < 0 || y2 >= cols)
- continue;
- if (matrix[x2][y2] <= matrix[x][y])
- continue;
- dp[x][y] = max(dp[x][y], dfs(x2, y2));
- }
- return ++dp[x][y];
- };
- int ans = 0;
- for (int i = 0; i < rows; ++i)
- for (int j = 0; i < cols; ++j)
- ans = max(ans, dfs(i, j));
- return ans;
- }
-};
-
-int main() {}