Pergunta de entrevista da empresa AKUNA CAPITAL

Leetcode medium difficulty, can't say specifics