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 954c7ef commit 4f95c59Copy full SHA for 4f95c59
646-maximum-length-of-pair-chain.js
@@ -1,3 +1,26 @@
1
+/**
2
+ * @param {number[][]} pairs
3
+ * @return {number}
4
+ */
5
+const findLongestChain = function(pairs) {
6
+ let res = 0
7
+ const n = pairs.length
8
+ if(n === 0) return res
9
+ pairs.sort((a, b) => a[1] - b[1])
10
+ let end = pairs[0][1]
11
+ res++
12
+ for(let i = 1; i < n; i++) {
13
+ const e = pairs[i]
14
+ if(e[0] <= end) continue
15
16
+ end = e[1]
17
+ }
18
+
19
+ return res
20
+};
21
22
+// another
23
24
/**
25
* @param {number[][]} pairs
26
* @return {number}
0 commit comments