p1 and p2 to 0.max_distance to 0.p1 < len(nums1) and p2 < len(nums2), do the following:
a. If nums1[p1] is greater than nums2[p2], increment p1.
b. Otherwise, if p2 - p1 is greater than max_distance, update max_distance to p2 - p1.
c. Increment p2.max_distance.