Wrong test case?


  • 0

    Why does the expected value for this test case is true?
    The abbreviation of "hello", i.e., h3o already exists in the dictionary.

    Input:
    ["hello"],isUnique("hello")
    Output:
    [false]
    Expected:
    [true]


  • 3
    Y

    I got the same problem when I submitted my solution for the first time.
    And then I guess that if the given word itself is in the dictionary, and it has the unique abbreviation, then we should return true.
    The result showed that my guess is right.


  • 3
    L

    Because in the problem it mentioned "A word's abbreviation is unique if no other word from the dictionary has the same abbreviation." As a result, only words that are different than the target word need to be checked for uniqueness.


Log in to reply
 

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