Clear Street Interview Question

Leetcode style problem, medium to hard difficulty