Bloomberg Interview Question

used notes to map out a coding question. could not understand