EnjoyAlgorithms
TagsReviewsStoriesContact

extra-space

1 article

Maximum Difference Between Two Elements in an Array

Maximum Difference in an Array

Given an array A[] of n integers, find out the maximum difference between any two elements such that the larger element appears after the smaller element. In other words, we need to find max(A[j] - A[i]), where A[j] > A[i] and j > i. Note: This is an excellent problem to learn problem-solving using divide and conquer and a single loop.

22 October 2026