Infosys Interview Question

joins based output