Binance Interview Question

Solve a medium LC question