PIMCO Interview Question

Basic coding question but need to think of algorithm to control efficiency