IBM interview question

leetcode qn based on array