Confusing description for contains duplicates III, I think


  • 5
    L

    Hi,

    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.

    Regards.


  • 0
    S

    I agree with you. The description is not very clear.


  • 1
    S

    Totally agree with you. I have a test case which presents the difference b/t using abs() and not.

    Input:
    [-1,-1], 1, -1
    Output:
    true
    Expected:
    false

    In this case, I think this one should be true instead of false.


  • 0
    H

    @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.


Log in to reply
 

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