Cyient Interview Question

It is difficult step by step