Cyient Interview Question

How to solve issue