Bloomberg interview question

counting problem, array problem