Domanda di colloquio di Juniper Networks

Leetcode Medium Question which I could solve