Spire Trading interview question

Leetcode data structure question