Wrong test case | Expected value incorrect


#1

A : [ -259, -825, 459, 825, 221, 870, 626, 934, 205, 783, 850, 398 ]
B : -42

Expected return value: 1
It should be 0.


#2

Yes wrong test case. Previously I didn’t consider B to be negative but then I saw in discussion this topic and checked it, found my code was throwing wrong answer for negative B values, so modified it, then this test case came. A request to interviewbit to correct this test case.


#3

No, its correct.
In the question it is written to find 2 numbers with difference of B (It does not say that first number should come before second number).
If A[ i ] - A[ j ] = B then A[ j ] - A[ i ] = negative of B . So if you can find two numbers (A[ i ] and A[ j ]) with 42 difference then there also exists two numbers (A[ j ] and A[ i ]) with -42 difference.
The solution should be regardless of sign of B.


#4

wrong test case :
A : [ -533, -666, -500, 169, 724, 478, 358, -38, -536, 705, -855, 281, -173, 961, -509, -5, 942, -173, 436, -609, -396, 902, -847, -708, -618, 421, -284, 718, 895, 447, 726, -229, 538, 869, 912, 667, -701, 35, 894, -297, 811, 322 ]
B : 369

Expected output : 1

It should be 2, as there are two pairs present for which difference is 369
{(-666,-297), (538,169))


#5

Ok, so which two numbers in that list have a difference of 42???


#6

A : [ -259, -825, 459, 825, 221, 870, 626, 934, 205, 783, 850, 398 ]
B : -42

The pair 825,783 have a difference of 42.
825 - 783 = 42 and 783 - 825 = -42
So Therefore its correct because it have the pair with -42 as difference.


#7

its not 825,783… but it is -825 and 783 so how will the difference be 42