✅A COMMON IDEA,🧐 O(n^2) where n is critical points
Intuition\n Describe your first thoughts on how to solve this problem. \nwe will store height of every critical points of our block except at end ,this way we w
### Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe will store height of every critical points of our block except at end ,this way we will always have height of every block with aleast one critical point and we can update height changes due to new blocks except by it end points.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#include <iostream>\n#include <vector>\n#include <set>\n#include <unordered_map>\n#include <algorithm>\n\nusing namespace std;\n\nclass Solution {\npublic:\n    vector<int> fallingSquares(vector<vector<int>>& positions) {\n        set<int> points;\n        for (auto& d : positions) {\n            points.insert(d[0]);\n            points.insert(d[0] + d[1]);\n        }\n        \n        unordered_map<int, int> index;\n        int n = 0;\n        for (auto& ele : points) index[ele] = n++;\n        \n        vector<int> height(n, 0);\n        vector<int> result;\n        int maxHeight = 0;\n\n        for (auto& p : positions) {\n            int li = index[p[0]];\n            int ri = index[p[0] + p[1]];\n            int currHeight = 0;\n\n            // Find the maximum height in the current interval [li, ri)\n            for (int j = li; j < ri; j++) {\n                currHeight = max(currHeight, height[j]);\n            }\n\n            // Update the height for the current interval [li, ri)\n            for (int j = li; j < ri; j++) {\n                height[j] = currHeight + p[1];\n            }\n\n            // Update the global maximum height and store the result\n            maxHeight = max(maxHeight, currHeight + p[1]);\n            result.push_back(maxHeight);\n        }\n        \n        return result;\n    }\n};\n\n```
['C++']