Citi interview question

Coding challenge - writing a function