Cognizant interview question

basic coding, logical reasoning and analysis