Skip to main content

Accenture

Accenture OA-8 2024

Problem Description

Ian has been given an array A of length N. He wants to find the sum of elements at even positions after reversing the array. Your task is to help him find and return an integer value representing the sum of the array elements present at even positions of the reversed array.

Input Format:

  • input1: A reversed integer array A.
  • input2: An integer N, representing the length of the array.

Output Format:

Return an integer value representing the sum of the array elements present at the even positions of the reversed array.

Constraints:

  • 1 ≤ N ≤ 10^5
  • 1 ≤ A[i] ≤ 10^9

Example

Sample Input:

input1: (10, 20, 30, 40, 50, 60)
input2: 6

Sample Output:

110

Explanation:
After reversing the array, it becomes (60, 50, 40, 30, 20, 10). The even positions are 0, 2, and 4. The sum of elements at these positions is 60 + 40 + 10 = 110. Therefore, the output is 110.