Juniper Square Interview Question

one LeetCode medium problem, solved live through CodeSignal