Optiver Interview Question

three coding questions. They are at leetcode medium