IMC Trading Interview Question

Solve a problem on hackerrank