## LeetCode 42H - Trapping Rain Water,双指针法 from typing import List class Solution: ## height 表示列表中元素的取值,高度 def trap(self, height: List[int]) -> int: if not height: ## 如果没有任何高度 return 0 ## 接不住任何雨水 ## 初始
After the rain, water is trapped between the blocks. The total volume of water trapped is4. https://leetcode.com/problems/trapping-rain-water-ii/discuss/89461/Java-solution-using-PriorityQueuehttps://www.youtube.com/watch?v=cJayBq38VYwclassSolution {publicinttrapRainWater(int[][] heightMap)...
42. Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. rainwatertrap.png For example,Given[0,1,0,2,1,0,1,3,2,1,2,1],return6.The above elevation mapisrepresented...