[leetcode] A Distance Maximizing Problem的疑问

阅读更多

http://leetcode.com/2011/05/a-distance-maximizing-problem.html

 

问题: Given an array A of integers, find the maximum of j-i subjected to the constraint of A[i] < A[j].

 

解法二:排序后的lookup table是用来做什么的,怎么构造的?

 

解法三:Generally, we want to choose only starting points with no such lines that are shorter to its left side. From the diagram above, only lines of index 0, 1, 3, 4 are valid starting points.  这一步是怎么在O(n)的时间内做到的?

 

 

你可能感兴趣的:(算法)