This function assumes that arr [ ] is sorted in increasing order according the first ( or smaller ) values in pairs .
int maxChainLength ( struct pair arr [ ] , int n ) { int i , j , max = 0 ; int * mcl = ( int * ) malloc ( sizeof ( int ) * n ) ;