Here’s the full text of the code from Episode 05. This is coded in JavaScript and uses the common approach of using a stack to keep track of the open rectangles.