I think that the description of the code challenge is not very fortunate. In fact, we need to think in terms of a "distance metric" for both the indices and the values of the vector. And as such the differences should be in terms of abs(). So abs(i-j) <= k and abs(nums[i] - nums[j]) <= t, I believe.
Totally agree with you. I have a test case which presents the difference b/t using abs() and not.
[-1,-1], 1, -1
In this case, I think this one should be true instead of false.
@szufour Agree. I think it depends on the way of treating corner case.
If I think the abs(difference) is always > 0, and the negative t should get a result of false;
Otherwise, I can simply correct the input t to zero if the input is negative, thus the result can be true.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.