Robinhood interview question

LC medium to hard problems