Robinhood interview question

Typical leetcode question with two steps