Simple TS
Intuition\nEach square landing should create an edge at some height, between two points that can catch the next square.\n\n# Approach\nKeep a list of edges that
# Intuition\nEach square landing should create an edge at some height, between two points that can catch the next square.\n\n# Approach\nKeep a list of edges that represent left, right and height. \nFor each of the squares, find all the edges that overlap the bounds of the square. \nFind which edge from those results is the highest call this intersection.\nPut another edge square height above the found intersection.\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$ I think, since the edges grow towards N with each iteration\n\n- Space complexity:\n$$O(n)$$ Since we keep track of N edges. \n\n# Code\n```\nfunction fallingSquares(positions: number[][]): number[] {\n    let maxHeight = 0\n    const answer:number[] = []\n    const edges:[number,number,number][] =[]\n    while(positions.length){\n        const [sLeft,sHeight] = positions.shift()\n        const sRight = sLeft+sHeight\n        let intersectionHeights:number[] = [0]\n        let maxFoundHeight = 0\n        for ( let i = edges.length -1; i >= 0 ; i--){\n            const testEdge = edges[i]\n            const [tl,tr,th] = testEdge\n            if(!intersectEdges(tl,tr,sLeft,sRight)) continue\n            intersectionHeights.push(th)\n            maxFoundHeight = Math.max(maxFoundHeight,th)\n        }\n        const nextHeight = maxFoundHeight+sHeight\n        maxHeight = Math.max(maxHeight,nextHeight)\n        edges.push([sLeft,sRight,nextHeight])\n        answer.push(maxHeight)\n    }\n    return answer\n};\n\nconst intersectEdges = (a:number,b:number,c:number,d:number)=>\n    Math.min(b,d)-Math.max(a,c) > 0\n```
['TypeScript']