Privalia Interview Question

Logic problem solved by using for loops