Using binary search , find the index in which the kth element will lie
while ( l <= h ) : NEW_LINE INDENT m = ( l + h ) // 2 NEW_LINE if ( total [ m ] > k ) : NEW_LINE INDENT index = m NEW_LINE h = m - 1 NEW_LINE DEDENT elif ( total [ m ] < k ) : NEW_LINE INDENT l = m + 1 NEW_LINE DEDENT else : NEW_LINE INDENT index = m NEW_LINE break NEW_LINE DEDENT DEDENT l = L [ index - 1 ] NEW_LINE h = R [ index - 1 ] NEW_LINE