# Does anyone else consider this problem not accurate

• The problem statement:
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is at most k.

So then if the following are true then return true:

nums[i] - nums[j] <=t and

i-j<=k

Then [4,2], 1,1 should be true:

2-4<=1 check

1-0<=1 check

return true;

So then you have to assume what they're asking for is:

abs(nums[i] - nums[j]) <=t and

abs(i-j)<=k

but then I propose the question of why offer a possible scenario of t<0.

Either way, this problem is not correct as written.

• I don't think so! The problem is ACCURATE!

In the problem, it does NOT state i > j or j > i.

Therefore, either could be true!

In your example, [4, 2], 1, 1

let i = 1 and j = 0, we get it correct!

• if i =1, j=0, the function should return true, but the solution set rejects true and expects false, which leads me to conclude the problem is incorrectly stated.

• Oh, sorry, it should be false! because 4 - 2 > 1

• Define i =1, j = 0, then the difference between nums[i] and nums[j] is 2-4 = -2, which is less than t = 1, and since i-j <=1, then the answer should be TRUE, based on the way the problem is worded.

Hence this problem is inaccurate

Do you see my point?

• =.=OK I see your point.....don't care about the detail...

• yes, I have same question as yours regards test cases of [4,2], 1, 1 and [-1,-1], 1, -1

• I think it doesn't make sense if t < 0. So just make sure that t >= 0 and abs(nums[j] - nums[i]) <= t.

• I too agree. It is very confusing. I don't know why are they giving t values as negative in the test cases. It does not align with instructions in the question. Seems like we should dig more information from the test cases rather than problem statement :-D

• [-1,-1], 1, -1

Agreed. Test case [-1,-1], 1, -1 troubles me.

• You should understand "absolute difference" first.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.