Pergunta de entrevista da empresa Optiver

I was given two simple LeetCode-style problems in C++, my primary language. I solved them with correct variations and explained my reasoning, including time and space complexity trade-offs