Grant Street Group Interview Question

Variation of Leetcode 828, lc hard