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

24th Apr 2021, 5:10 AM
Disha Jain
3 Antworten
+ 1
You have to show your code or at least explain what is the problem
24th Apr 2021, 5:15 AM
Michal Doruch
0
This is the hackerearth questions...n I need explanation and coding of this problem
24th Apr 2021, 5:18 AM
Disha Jain
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
24th Apr 2021, 5:27 AM
Michal Doruch