Capgemini interview question

Dense group case