AVASOFT interview question

Coding logics for a array problem.