Cognizant interview question

Initial Coding round with 2 problems