Midpoint Markets interview question

The technical interview (2nd) was a leetcode medium.