way.com interview question

To code based on the give inputs?