You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// let left x has negative height to ensure left x goes to multiset first if with same 'x' as right x // add before removing is imp in case of same right x of one building and left x of other building
14
+
xaxis.push_back(make_pair(b[0], -b[2]));
15
+
xaxis.push_back(make_pair(b[1], b[2]));
16
+
}
17
+
sort(xaxis.begin(), xaxis.end()); // sort walls
18
+
multiset<int>leftxHeights = {0};// keep left x heights sorted; dummy'0'for convenience
19
+
int mhabtpi = 0; // current max height among leftxHeights
20
+
for (auto xh : xaxis) {
21
+
if (xh.second < 0) { // it's a left x, insert the height
22
+
leftxHeights.insert(-xh.second);
23
+
}
24
+
else { // it's a right x, delete the height
25
+
leftxHeights.erase(leftxHeights.find(xh.second));
26
+
}
27
+
28
+
if (*leftxHeights.rbegin() != mhabtpi) { // mark a skyline point
0 commit comments