Bloomberg Interview Question

counting problem, array problem