Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 712 Bytes

Question_1385.md

File metadata and controls

30 lines (25 loc) · 712 Bytes

LeetCode Records - Question 1385 Find the Distance Value Between Two Arrays

Attempt 1: Use a loop

class Solution {
    public int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
        int count = 0;

        for (int i = 0; i < arr1.length; i++) {
            boolean isGood = true;
            for (int j = 0; j < arr2.length; j++) {
                if (Math.abs(arr1[i] - arr2[j]) <= d) {
                    isGood = false;
                    break;
                }
            }

            if (isGood) {
                count++;
            }
        }

        return count;
    }
}
  • Runtime: 4 ms (Beats: 51.06%)
  • Memory: 44.04 MB (Beats: 43.35%)