Citi Interview Question

Coding challenge - writing a function