Arista Networks Interview Question

An average difficulty problem on leetcode