Pergunta de entrevista da empresa Juniper Networks

Leetcode Medium Question which I could solve