Mambu interview question

A coding problem from Hackerrank.