Skip to content

Commit

Permalink
✨ feat: 456. 132 模式;
Browse files Browse the repository at this point in the history
  • Loading branch information
ConteMan committed Mar 24, 2021
1 parent e90f903 commit 0d067dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 456-132-pattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @param {number[]} nums
* @return {boolean}
*/
var find132pattern = function(nums) {
const n = nums.length;
if (n < 3) {
return false;
}

let startValue = 0;
let middleValue = 0;
let lastValue = 0;

for ( let j = 1; j < n - 1; j ++) {
const leftNum = nums[j-1];
if ( leftNum < startValue || j == 1 ) {
startValue = leftNum
}
middleValue = nums[j];
if ( startValue >= middleValue ) {
continue;
}
for ( let k = j + 1; k < n; k++ ) {
lastValue = nums[k];
if ( lastValue > startValue && middleValue > lastValue ) {
return true;
}
}
}
return false;
};
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Record LeetCode.

[456. 132 模式](./456-132-pattern.js)
[1672. 最富有客户的资产总量](./1672-richest-customer-wealth.js)
[73. 矩阵置零](./73-set-matrix-zeroes.js)
[26. 删除有序数组中的重复项](./26-remove-duplicates-from-sorted-array.js)

0 comments on commit 0d067dd

Please sign in to comment.