File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @param {number[] } nums
3+ * @return {boolean }
4+ */
5+ var find132pattern = function ( nums ) {
6+ const n = nums . length ;
7+ if ( n < 3 ) {
8+ return false ;
9+ }
10+
11+ let startValue = 0 ;
12+ let middleValue = 0 ;
13+ let lastValue = 0 ;
14+
15+ for ( let j = 1 ; j < n - 1 ; j ++ ) {
16+ const leftNum = nums [ j - 1 ] ;
17+ if ( leftNum < startValue || j == 1 ) {
18+ startValue = leftNum
19+ }
20+ middleValue = nums [ j ] ;
21+ if ( startValue >= middleValue ) {
22+ continue ;
23+ }
24+ for ( let k = j + 1 ; k < n ; k ++ ) {
25+ lastValue = nums [ k ] ;
26+ if ( lastValue > startValue && middleValue > lastValue ) {
27+ return true ;
28+ }
29+ }
30+ }
31+ return false ;
32+ } ;
Original file line number Diff line number Diff line change 11Record LeetCode.
22
3+ [ 456. 132 模式] ( ./456-132-pattern.js )
34[ 1672. 最富有客户的资产总量] ( ./1672-richest-customer-wealth.js )
45[ 73. 矩阵置零] ( ./73-set-matrix-zeroes.js )
56[ 26. 删除有序数组中的重复项] ( ./26-remove-duplicates-from-sorted-array.js )
You can’t perform that action at this time.
0 commit comments