Pregunta de entrevista de Deloitte

Asked on java streams which was tough one