aboutsummaryrefslogtreecommitdiff
path: root/other/trapping_rain_water.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
committerJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
commita96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch)
treee2a2b3f49f9fb741be81415266ac93e74cff42ec /other/trapping_rain_water.cpp
parent694ad5ed71edcb1deccab54b72d706b779918276 (diff)
downloadleetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz
leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/trapping_rain_water.cpp')
-rw-r--r--other/trapping_rain_water.cpp33
1 files changed, 0 insertions, 33 deletions
diff --git a/other/trapping_rain_water.cpp b/other/trapping_rain_water.cpp
deleted file mode 100644
index d2ced43..0000000
--- a/other/trapping_rain_water.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- int trap(vector<int> &height) {
- if (height.size() <= 2)
- return 0;
- int n = height.size(), maxLeft = height[0], maxRight = height[n - 1];
- int left = 1, right = n - 2, ans = 0;
- while (left <= right) {
- if (maxLeft < maxRight) {
- if (height[left] > maxLeft)
- maxLeft = height[left];
- else
- ans += maxLeft - height[left];
- left += 1;
- } else {
- if (height[right] > maxRight)
- maxRight = height[right];
- else
- ans += maxRight - height[right];
- right -= 1;
- }
- }
- return ans;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> height = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
- cout << obj.trap(height);
-}