Zillow Interview Question

It was a leetcode hard