1. Given two integer arrays a and b, and an integer value d, your task is to find the comparator value between these arrays.

    The comparator value is defined as the number of elements x ∈ a such that there are no elements y ∈ b where |x - y| ≤ d. In other words, it's the number of elements in a that are more than d away from any element of b.

    Return the comparator value as an integer.

    For eg. a = [2, 9] and b = [16, 13, 8], d = 3 should return 1.

    n = 9
    9 - 16 = 7 > 3
    9 - 13 = 4 > 3
    9 - 8 = 1 < 3

    n = 2
    2 - 16 = 14 > 3
    2 - 13 = 11 > 3
    2 - 8 = 6 > 3

  2. We define a subarray of size m in an n-element array to be the contiguous block of elements in the inclusive range from index i to index j, where j − i + 1 = m and 0 ≤ i ≤ j < n. For example, given array [8, 2, 4], the subarrays of size m = 2 would be [8, 2] and [2, 4] (but not [8, 4] since these elements aren't contiguous).

    Given an array of integers arr, and an integer m, your task is the following:

    Find the minimum value in each of the contiguous subarrays of size m;
    Return the maximum value among these minimums.
    Complete the maxMinInSegments function in the editor to make it return the needed value.

Comments (19)