Question: I want you to write a Java program to find the best time period. There will be input data: 5 7 - 1 - 2

I want you to write a Java program to find the best time period.
There will be input data:
57
-1-2-32-710-10
The output is 10(I don't understand why it's 10)
5 is the maximum sum of consecutive elements.
7 is the total number of elements in the array.
Input data:
35
-124-15
The output is 8(because the sum of the three consecutive elements is the highest, which is 4-15=8)
Input data:
210
-1-25401-8-18-5
The output is 9(because the sum of the three consecutive elements is the highest, which is 54=9)
I don't understand why the output for the first example is 10.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!