Extreme Networks interview question

The question is pretty similar to the Leetcode problems