```
int findLongestChain(vector<vector<int>>& pairs) {
sort(pairs.begin(), pairs.end(), [](vector<int>& a, vector<int>& b){ return a[1] < b[1]; });
int res = 0, curEnd = INT_MIN;
for (auto& p : pairs)
if (curEnd < p[0]) curEnd = p[1], ++res;
return res;
}
```