Flow Traders interview question

Solve a medium leetcode problem