T-Systems Interview Question

Coding question on java stream