SOTI Interview Question

Output for code and logic implementation