Tesco interview question

Difficulty task how would you solve it