I found the difference between
nums[j] can be negative in the problem Contains Duplicate III. So if the difference between
j can be negative, the result will be really different in this problem.
[1, 0, 1]
results in answer
0 - 2 = -2 < 1?
The difference between i and j should be restricted to be non-negative.