Please give the solution code using arrays. Not able to understand the logic and functionality of the question.