NTT DATA Interview Question

coding problem on string and one array problem