way.com Interview Question

To code based on the give inputs?