c++ map: maintain the disjoint intervals
\nclass Solution {\npublic:\n    vector<int> fallingSquares(vector<vector<int>>& positions) {\n        map<pair<int, int>, int> i2h;\n        int g_max = 0;\n  
```\nclass Solution {\npublic:\n    vector<int> fallingSquares(vector<vector<int>>& positions) {\n        map<pair<int, int>, int> i2h;\n        int g_max = 0;\n         vector<int> ret; \n        for(auto &p: positions){\n            int left = p[0];\n            int size = p[1];\n            int right = left + size;\n            int height = size; \n            \n            auto it = i2h.lower_bound(make_pair(left , right));\n            if(it != i2h.begin()){\n                auto it2 = it;\n                it2--;\n                if(it2->first.second > left) {\n                    it = it2; \n                }\n            }\n            \n            int maxheight = 0;\n            while(it != i2h.end()){\n                if(it->first.first >= right) break;\n                \n                if(it->first.first < left) {\n                    i2h[make_pair(it->first.first, left)] = it->second;  \n                }\n                if(it->first.second > right) {\n                    i2h[make_pair(right, it->first.second)] = it->second;  \n                }\n                maxheight = max(maxheight, it->second);\n                \n                it = i2h.erase(it);\n                \n            }\n            \n            i2h[make_pair(left, right)] = maxheight + height; \n            g_max = max(g_max, maxheight + height);\n            ret.push_back(g_max);\n            \n        }\n        return ret;\n    }\n};\n```
[]