Apply binary search to find the number of intervals completely lying to the left of the ith interval
while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( v [ mid ] . second < start ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } }