leetcode:Trapping Rain Water
来源:互联网 发布:桌面定时提醒软件 编辑:程序博客网 时间:2024/06/05 21:57
class Solution {public: int trap(int A[], int n) { if(n <= 0) return 0; int * water = new int[n]; int current =0; for(int i=0 ;i<n;i++) { current = max(current,A[i]); water[i] = current; } current = 0; for(int i =n-1;i>=0;i--) { current = max(current,A[i]); water[i] = min(water[i],current); } int result = 0; for(int i =0; i < n;i++) { result += water[i]-A[i]; } delete [] water; return result; }};
0 0
- LeetCode: Trapping Rain Water
- LeetCode : Trapping Rain Water
- [LeetCode] Trapping Rain Water
- [Leetcode] Trapping Rain Water
- [Leetcode] Trapping Rain Water
- [LeetCode]Trapping Rain Water
- LeetCode-Trapping Rain Water
- [leetcode] Trapping Rain Water
- [LeetCode] Trapping rain water
- Leetcode: Trapping Rain Water
- Leetcode:Trapping Rain Water
- [LeetCode] Trapping Rain Water
- <Leetcode>Trapping Rain Water
- Leetcode Trapping Rain Water
- leetcode Trapping Rain Water
- leetcode Trapping Rain Water
- LeetCode Trapping Rain Water
- LeetCode | Trapping Rain Water
- 第十四周项目6-阅读程序1(对continue的理解)
- 【c++程序】深层复制构造函数
- ril的部分解析
- ubantu下gcc编译器的安装、vim安装以及第一个helloworld的测试
- 数据结构与算法分析笔记(8)——二叉树和树
- leetcode:Trapping Rain Water
- TCP,UDP,Socket和HTTP
- 第四章 Hook键盘中断和IOAPIC重定位
- 网络 TCP net 服务端和客户端进行连接 io SerrverSocket Socket(accept) Thread
- JAVA : reference
- Eclipse调试Bug的七种常用技巧
- Spring data JPA中使用Specifications动态构建查询
- 【web++_第三阶段_SpringMVC初级进阶(第一篇:必看)】SpringMVC初级进阶(第一篇:必看)_2
- 【阅读】《head first jquery》(第十章)——jquery UI