CareerCup Given an array A[], find (i, j) such that A[i] < A[j] and (j - i) is maximum.
来源:互联网
O(n) time and O(n) space solution. Tested! The key observation is the two auxiliary arrays LMin and RMax which saves the smallest value left of i and biggest value right of iO(n) time and O(n) space solution. Tested! The key