class Solution {
public int maxDistance(int[] nums1, int[] nums2) {
int max = 0;
for (int i = 0, len1 = nums1.length, len2 = nums2.length; i < len1; i++) {
for (int j = i + max; j < len2; j++) {
if (nums2[j] >= nums1[i]) max = Math.max(max, j - i);
else break;
}
}
return max;
}
}