Cognizant Interview Question

Initial Coding round with 2 problems