Arista Networks Interview Question

Divide and conquer problem in C++