FinYX Interview Question

implement missing logic in existing code