Find the Maximum Difference
You are given a sequence of integers S, your task is to find a pair i,j of indices with i<j that maximizes the difference S[j]-S[i].
Note that what makes this challenge more interesting is the requirement of order, that i < j (without it you simply need to find the maximum and minimum element of S).
You have to output the value of the maximum difference.
Input Format An integer N followed by N space separated integers S[i] on a new line.
[Read More]