Cognizant interview question

Simple ds problem and programming