forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
752d36a
commit 21e4e6d
Showing
1 changed file
with
3 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 775.Global-and-Local-Inversions | ||
|
||
对于A[i]而言,它不在乎A[i-1]是否比它大。即使比它大,也只是引入了一个local inversion,而不会有额外的global inversion。而要避免牵扯更多的global inversion,唯一的要求就是第i-2个元素及之前的所有元素都要比A[i]小。于是我们可以在遍历元素i的过程中,维护一个curMax,记录的是从第0个元素到第i-2个元素的最大值。只要出现```curMax > A[i]```即返回false。 |