aboutsummaryrefslogtreecommitdiff
path: root/path_min_effort.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /path_min_effort.cpp
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'path_min_effort.cpp')
-rw-r--r--path_min_effort.cpp34
1 files changed, 0 insertions, 34 deletions
diff --git a/path_min_effort.cpp b/path_min_effort.cpp
deleted file mode 100644
index 0b93590..0000000
--- a/path_min_effort.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- int minimumEffortPath(vector<vector<int>> &heights) {
- int m = heights.size(), n = heights[0].size();
- int dirs[5] = {-1, 0, 1, 0, -1};
- vector<vector<int>> efforts(m, vector<int>(n, INT_MAX));
- priority_queue<pair<int, int>, vector<pair<int, int>>,
- greater<pair<int, int>>>
- pq;
- pq.emplace(0, 0);
- while (!pq.empty()) {
- int effort = pq.top().first;
- int x = pq.top().second / 100, y = pq.top().second % 100;
- pq.pop();
- if (x == m - 1 && y == n - 1)
- return effort;
- if (effort >= efforts[x][y])
- continue;
- efforts[x][y] = effort;
- for (int i = 0; i < 4; i++) {
- int nX = x + dirs[i], nY = +dirs[i + 1];
- if (nX < 0 || nX >= m || nY < 0 || nY >= n)
- continue;
- int nEffort = max(effort, abs(heights[x][y] - heights[nX][nY]));
- pq.emplace(nEffort, nX * 100 + nY);
- }
- }
- return -1;
- }
-};
-
-int min() {}