Bloomberg Interview Question

Matlab coding