Flow Traders interview question

Writing an algorithm, explaining complexity, talking about edge cases, and making it thread safe.