Find the max. difference between two array elements a[j] and a[i] such that j > i
The algorithm you're using does a bunch of superfluous work. It would be much more efficient to concentrate on tracking the maximum difference that conforms to the specification than where you are in the array.

Setting the maxIndex the first time through your main loop isn't really setting any meaningful limit for you, because you also need to check to see if there are any other number combinations that have a higher difference than just the array maximum. In fact, you don't need to know what the highest value is at all or it's position in the array. The highest difference already assumes both of these, because when you set the greatest difference it is calculated based on the lowest value up to the current point in the array.

The idea of limiting the minimum check to the position of the previous high is well intentioned, but why not just run through the array once and keep track of everything at the same time? 

The pseudo-code is much simpler:


Set the first value in the array to your low value. 
Loop through the
array. 
If the current element minus the low value is higher than the
maximum difference found, update the maximum difference. 
If the current element is lower than the previous low, update the previous
low value. 
Return the maximum difference when you hit the end of the array.