Skip to content

Commit 6b45b9a

Browse files
committed
Add Solution
1 parent 76b88ea commit 6b45b9a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {number[][]} pairs
3+
* @return {number}
4+
*/
5+
var findLongestChain = function (pairs) {
6+
pairs.sort((a, b) => a[1] - b[1]);
7+
8+
let cur = Number.MIN_SAFE_INTEGER,
9+
ans = 0;
10+
11+
for (const [start, end] of pairs) {
12+
if (cur < start) {
13+
cur = end;
14+
ans++;
15+
}
16+
}
17+
18+
return ans;
19+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
| 23 | [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/) | [JavaScript](./Problems/23-merge-k-sorted-lists.js) | Hard |
3838
| 68 | [Text Justification](https://leetcode.com/problems/text-justification/) | [JavaScript](./Problems/68-text-justification.js) | Hard |
3939
| 97 | [Interleaving String](https://leetcode.com/problems/interleaving-string/) | [JavaScript](./Problems/97-interleaving-string.js) | Medium |
40+
| 646 | [Maximum Length of Pair Chain](https://leetcode.com/problems/maximum-length-of-pair-chain/) | [JavaScript](./Problems/646-maximum-length-of-pair-chain.js) | Medium |

0 commit comments

Comments
 (0)