0
Solve this code in any language java python C c++
You are given an array of size , where the integer of the array is and its value ranges between and inclusive. You are required to complete the following task: Assume that you are provided with additional numbers , , and . Your task is to report the number of unordered pairs of elements from this array, such that , , and . Input format First line: Four space-separated integers , , , and Next line: space-separated integers where the integer denotes Output format Print the required number of ordered pairs of array elements in a single line. As the answer could be rather large, be careful of integer overflows. Constraints Sample Input 5 2 1 0 1 2 3 2 1 Sample Output 6
3 Antworten
+ 1
You have to show your code or at least explain what is the problem
0
This is the hackerearth questions...n I need explanation and coding of this problem
0
Looks like you have to check how many pairs of integers there are, where for example:
(a[i] == a[i+1] - 1) or (a[i] == a[i+1] + 1)
You have to iterate thru both arrays and check for these pairs