Skip to main content

Accenture

Accenture OA-20 2024

Problem Description

You are given an integer array of size N, representing jars of chocolates. Three students A, B, and C, will pick chocolates one by one from each chocolate jar, till the jar is empty, and then repeat the same with the rest of the jars. Your task is to find and return an integer value representing the total number of chocolates that student A will have, after all the chocolates have been picked from all the jars.

Input Format:

  • input1: An integer array representing the quantity of chocolates in each jar.
  • input2: An integer value N representing the number of jars.

Output Format:

Return an integer value representing the total number of chocolates that student A will have, after all the chocolates are picked.

Constraints:

  • Number of Jars (N): 1≤N≤10^5 : The number of jars
  • Chocolates in Each Jar (input1): The array input1 has a size of 𝑁
  • Each element in the array represents the number of chocolates in each jar.
  • 1≤input1[i]≤10^6 : The quantity of chocolates in each jar.

Example

Sample Input:

input1: [3, 2, 6]
input2: 3

Sample Output:

4

Explanation:
Jar 1: A takes 1, B takes 1, C takes 1.

  • Jar 2: A takes 1, B takes 1.
  • Jar 3: A takes 1, B takes 1, C takes 1, A takes 1, B takes 1, C takes 1.

So, A gets a total of 1 + 1 + 1 + 1 = 4 chocolates.