You may solve this problem with brute-force: Build an array \(h[x]\) of heights indexed by \(x\)-coordinate initialized to \(0\).