```
public int findLongestChain(int[][] pairs) {
// sort
Arrays.sort(pairs, (a, b) -> (a[1]-b[1]));
int max = 1;
int index = 0;
for(int i = 1;i<pairs.length;i++){
if(pairs[index][1]<pairs[i][0]){
max++;
index = i;
}
}
return max;
}
```