educative.io

Interval intersection

Why we are taking end part to move our pointers ?? Can you please explain the below code

# move next from the interval which is finishing first

    if intervals_a[i][end] < intervals_b[j][end]:

      i += 1

    else:

      j += 1