Sort both the arrays
A . sort ( ) NEW_LINE B . sort ( ) NEW_LINE winA = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT val = A [ i ] NEW_LINE start = 0 NEW_LINE end = M - 1 NEW_LINE index = - 1 NEW_LINE DEDENT