Divide and Conquer Algo to find maximum difference between two ordered elements
问题 Given an array arr[] of integers, find out the difference between any two elements such that larger element appears after the smaller number in arr[]. Max Difference = Max { arr[x] - arr[y] | x > y } Examples: If array is [2, 3, 10, 6, 4, 8, 1, 7] then returned value should be 8 (Diff between 10 and 2). If array is [ 7, 9, 5, 6, 3, 2 ] then returned value should be 2 (Diff between 7 and 9) My Algorithm: I thought of using D&C algorithm. Explanation 2, 3, 10, 6, 4, 8, 1, 7 then 2,3,10,6 and 4