Dealpath Interview Question

Standard Leet code medium problem