Arista Networks interview question

A Leet Code type problem.