```
public int findLongestChain(int[][] pairs) {
int res = 0;
Arrays.sort(pairs, (a,b)->a[0]-b[0]);
int reach = Integer.MIN_VALUE;
for(int[] pair : pairs){
if(pair[0]>reach){
res++;
reach = pair[1];
}
else if(pair[1]<reach) reach = pair[1];
}
return res;
}
```