Forvis Mazars Group interview question

How to avoid nested loops?