Privalia interview question

Logic problem solved by using for loops