码迷,mamicode.com
首页 > 移动开发 > 详细

leetcode407 Trapping rain water II

时间:2020-10-29 10:06:29      阅读:25      评论:0      收藏:0      [点我收藏+]

标签:rom   queue   tool   lower   asi   dir   contain   blocks   priority   

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

标签:rom   queue   tool   lower   asi   dir   contain   blocks   priority   

原文地址:https://www.cnblogs.com/Marigolci/p/13891749.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!