Cognizant interview question

Solving a code challenge .