The Skyline Problem
来源:互联网 发布:防御矩阵2 编辑:程序博客网 时间:2024/05/08 02:24
// 超时class Solution {public: vector<pair<int, int> > getSkyline(vector<vector<int>>& buildings) { vector<pair<int, int> > r; if (buildings.size() == 0) { return r; } r.push_back(make_pair(buildings[0][0], buildings[0][2])); set<int> tmp; for (int i = 0; i < buildings.size(); ++i) { tmp.insert(buildings[i][0]); tmp.insert(buildings[i][1]); } set<int>::iterator a = tmp.begin(); set<int>::iterator b = ++a; for (; b != tmp.end(); ++b, ++a) { int max = 0; for (int i = 0; i < buildings.size(); ++i) { if (buildings[i][1] < *a) { continue; } if (buildings[i][0] > *b) { break; } max = max > buildings[i][2] ? max : buildings[i][2]; } if (max != r.back().second) { r.push_back(make_pair(*b, max)); } } return r; }};
0 0
- 105 - The Skyline Problem
- leetcode - The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- LeetCode - The Skyline Problem
- leetcode:the skyline problem
- LeetCode218:The Skyline Problem
- The Skyline Problem -- leetcode
- Leetcode -- The Skyline Problem
- 218 .The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- The Skyline Problem
- CSS3文字立体效果
- android 实践 - 2015-7-12
- 关于mac开机时的一些命令
- hdu 1285 确定比赛名次
- Hbase namespace问题
- The Skyline Problem
- Tortoise SVN的使用方法
- mysql必知必会(五)
- Redhat_Linux_9.0在vmware下不能上网的解决方法
- 聊聊为何不在项目中使用 CoffeeScript 与 Less (zihua.li)
- ioctl在socket中的一些用法及示例
- 怎样设置花生壳的端口映射
- 053第521题
- hdu 2087 减花布条 kmp