Cognizant interview question

2 coding question and queries