AVASOFT Interview Question

Coding logics for a array problem.