Skip to content

Latest commit

 

History

History
15 lines (14 loc) · 390 Bytes

1855. 下标对中的最大距离.md

File metadata and controls

15 lines (14 loc) · 390 Bytes
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;
    }
}