Arista Networks interview question

An average difficulty problem on leetcode