Pergunta de entrevista da empresa SpaceX

1 leetcode question, around medium difficulty