Pergunta de entrevista da empresa Nabla

leetcode hard question, be prepared with multiple solutions, the guy interviewing you only knows the solution he has in his brain, if you don't show him that solution, it's over