Vodafone Interview Question

How I solved the task