J.P. Morgan Interview Question

Question related to C++