Arista Networks Interview Question

Basic algorithm question in C.