You are given two integer arrays, nums1 and nums2, each containing n elements, and an integer diff. Consider all index pairs (i, j) where i < j. A pair is considered valid if the following condition holds:
Your task is to determine how many such valid pairs exist and return that total.
If no pair satisfies the condition, return 0.
Input: nums1 = [1,4,2] nums2 = [1,1,1] diff = 0
Output: 2
Explanation:
Valid pairs: (0,1): 1 - 4 <= 1 - 1 → -3 <= 0 ✓ (0,2): 1 - 2 <= 1 - 1 → -1 <= 0 ✓
Input: nums1 = [5,5,5] nums2 = [1,2,3] diff = 1
Output: 3
Explanation:
Every pair satisfies because values in nums1 are equal. Valid pairs: (0,1), (0,2), (1,2)
Accepted:
Submission: