#84. 数组差异计数
数组差异计数
Array Difference Count
Background
Dawei is organizing two sets of data. He wants to know how many pairs of corresponding elements in these two sets are "close but not identical".
Problem Description
Given arrays nums1 and nums2 of the same length, for every element in nums1, consider the corresponding element in nums2 (at the same index). Return the count of the number of times that the absolute difference between the two elements is less than or equal to , but they are not equal.
Input Format
Input is given from standard input in the following format.
One line, containing two integer lists enclosed in square brackets, with numbers in the lists separated by spaces. The first list represents
nums1, and the second list representsnums2.
Output Format
Output is printed to standard output in the following format.
An integer, representing the count of pairs that satisfy the conditions.
Sample
[1 2 3] [2 3 10]
2
[1 2 3] [2 3 5]
3
[1 2 3] [2 3 3]
2
Sample Explanation
For Sample 1:
nums1[0]=1,nums2[0]=2. , which satisfies and . Count.nums1[1]=2,nums2[1]=3. , which satisfies and . Count.nums1[2]=3,nums2[2]=10. , which does not satisfy . Do not count. Total 2 pairs.
For Sample 3:
nums1[0]=1,nums2[0]=2. , which satisfies and . Count.nums1[1]=2,nums2[1]=3. , which satisfies and . Count.nums1[2]=3,nums2[2]=3. , which satisfies , but does not satisfy . Do not count. Total 2 pairs.
Constraints
Time limit for each test case is 1 second, and memory limit is 1024KB.