leetcode407 Trapping rain water II
Posted Marigolci
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode407 Trapping rain water II相关的知识,希望对你有一定的参考价值。
use 3D version to calculate how much water the model can contain
this problem need use dfs,from the edge part which mustn‘t be answer,for the edge cannot contain water,so push these edge part into queue first.because we need dfs blocks from the lower part to the higher,so need special priority_queue greater type,we can grep block from lower to higher.
MAIN THOUGHT:
the main thought is sea level,use an increasing value represent sea level,
a queue store the block been visited
STORE TOOL:
priority_queue<pair<int,int>,greater>
vector<vector<bool>> visited
sea [record now sea level height]
res [record total answer]
ATTENTION:
initialize vector use = or directly follow {} also can be.
priority_queue need use push,if push type pair<int,int> need use {} wrap two value
以上是关于leetcode407 Trapping rain water II的主要内容,如果未能解决你的问题,请参考以下文章
leetcode407 Trapping rain water II
[leetcode] 407. Trapping Rain Water II