class Solution { public: vector<int> findBuildings(vector<int>& heights) { vector<int> res; for (int n = size(heights), i = 0; i < n; ++i) { while (!empty(res) && heights[res.back()] <= heights[i]) { res.pop_back(); } res.push_back(i); } return res; } };
|