Cognizant GenC Elevate Sample Coding Question 5

Question 5

In this article, we will discuss about Coding Question with their solution in  java. In this Question , we have to find maximum number of bulbs jasleen can collect , starting from any machine and collecting from every consecutive machine until shre reaches the last machine she wants to collect from.

Question 5

Question 5

Jasleen has bought a new bulb factory. The factory has a single file of machines, numbered from 1 to N. Each machine has a certain number of fully prepared bulbs.
Jasleen has a rule she wants to follow. She wants to collect an equal amount of bulb from
each machine from which she collects bulbs.

Jasleen can start collecting bulb from any machine, but once she starts collecting, she collects
from every consecutive machine until she reaches the last machine she wants to collect from. Find the maximum number of bulbs she can collect.

Input Specification:
Input1: N, the number of machines
Input2: An array of N elements (a1,a2 a3……aN], denoting the number of fully prepared bulbs in each machine of the factory.

Output Specification:
An integer output denoting the maximum number of bulbs that Allie can collect.

Example 1:
input1: 3
Input2: [1,2,3]

Output: 3

Example 2:
input1: 4
Input2: [5,8,9,10]

Output: 20