RippleHire Interview Question

Modify a code snippet for the given output