Cognizant Interview Question

they asked me to solve a snippet