Accenture Interview Question

Avg dsa question of moderate logic