Sale!

Find maximum difference

Original price was: $35.00.Current price is: $30.00.

Category:
Rate this product

Find maximum difference
Divide and Conquer

Given an array A, write a program to find the max(A[j]-A[i]) where i < j. If max(A[j]-A[i])<0, output 0. The input will start with an integer n, which indicates the length of the given array. The next line will be the array.

Example 1

Input:
2
1 5
Output:
4
Example 2:

Input:
4
1 5 8 2
Output:
7
Example 3:

Input:
6
8 7 4 3 2 1
Output:
0

Reviews

There are no reviews yet.

Be the first to review “Find maximum difference”

Your email address will not be published. Required fields are marked *

Scroll to Top