Question: class Solution { public int solution ( int [ ] A ) { int maxIncome = 0 ; for ( int i = 1 ;

class Solution { public int solution(int[] A){ int maxIncome =0; for (int i =1; i < A.length; i++){ if (A[i]> A[i -1]){ maxIncome += A[i]- A[i -1]; }} return maxIncome %1_000_000_000; }} run this code with input Example test: 14,1,2,3] WRONG ANSWER (got 2 expected 6) Example test: 17.2,3,3,2,1,51 WRONG ANSWER (got 6 expected 7)

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 Programming Questions!