HCLTech Interview Question

WAP for GCD