We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 44a4231 commit e2890a5Copy full SHA for e2890a5
334-increasing-triplet-subsequence.js
@@ -12,3 +12,26 @@ const increasingTriplet = function(nums) {
12
}
13
return false;
14
};
15
+
16
+// another
17
18
+/**
19
+ * @param {number[]} nums
20
+ * @return {boolean}
21
+ */
22
+const increasingTriplet = function(nums) {
23
+ const n = nums.length, stk = []
24
+ for(let e of nums) {
25
+ let l = 0, r = stk.length
26
+ while(l < r) {
27
+ const mid = l + Math.floor((r - l) / 2)
28
+ if (e > stk[mid]) l = mid + 1
29
+ else r = mid
30
+ }
31
32
+ stk[l] = e
33
+ if(stk.length > 2) return true
34
35
36
+ return false
37
+};
0 commit comments