python3 bisect solution
```\nfrom bisect import bisect_left as bl, bisect_right as br\nclass Solution:\n    def fallingSquares(self, positions: List[List[int]]) -> List[int]:\n        
```\nfrom bisect import bisect_left as bl, bisect_right as br\nclass Solution:\n    def fallingSquares(self, positions: List[List[int]]) -> List[int]:\n        ans, xs, hs = [], [0], [0]\n        for (x, h) in positions:\n            i, j = br(xs, x), bl(xs, x+h)\n            H = max(hs[max(i-1, 0):j], default = 0) + h\n            xs[i:j] = [x, x + h]\n            hs[i:j] = [H, hs[j - 1]]\n            ans.append(H)\n            if len(ans) > 1:\n                ans[-1] = max(ans[-1], ans[-2])\n        return ans
[]