Extreme Networks Interview Question

The question is pretty similar to the Leetcode problems