Cognizant interview question

Coding questions and some theory