Amazon Prime Air Delivery Route - Company-specific OAs / Amazon OA

https://algo.monster/problems/amazon_oa_prime_air_route

thank you

empty?

I was wondering when the problem statement will get posted?

This is removed by Amazon.

I received this question on their OA a month ago, its still in their rotation

Googling the questions it turns out that is the same problem as https://algo.monster/problems/optimal_utilization with a different description in the context of the Amazon Prime Air Route.

https://leetcode.com/discuss/interview-question/1025705/Amazon-or-OA-or-Prime-Air-time/824897
It seems to be a duplicate of https://algo.monster/problems/optimal_utilization

public static int[] primeAirTime(int[][] arr1, int[][] arr2, int k) {
        int[] res = new int[]{-1, -1};
        Arrays.sort(arr1, (a, b) -> a[1] - b[1]);
        Arrays.sort(arr2, (a, b) -> a[1] - b[1]);

        int minDiff = Integer.MAX_VALUE;
        int i = 0, j = arr2.length - 1;
        while (i < arr1.length && j >= 0) {
            if (minDiff > Math.abs(k - arr1[i][1] - arr2[j][1])) {
                minDiff = Math.abs(k - arr1[i][1] - arr2[j][1]);
                res[0] = arr1[i][0];
                res[1] = arr2[j][0];
            }

            if(k >= arr1[i][1] + arr2[j][1])
                i++;
            else
                j--;
        }

        return res;
    }