Solve interval, grid-fill, and heap tasks | Apple Interview Question