The description is wrong!


  • 3
    Y

    with input:
    [
    "wrt",
    "wrf",
    "er",
    "ett",
    "rftt"
    ]
    The correct order is: "wertf". -> this is wrong, the correct answer should be "werft", right?


  • 1

    No, it's correct. The first two words are "wrt" and "wrf", which shows that "t" comes before "f".


  • 0
    Y

    what about "rftt" -> this indicates f comes before t right?


  • 0
    Y

    "wrt" and "wrf" -> why this indicates t comes before f?


  • 0

    what about "rftt" -> this indicates f comes before t right?

    No, one word alone indicates nothing about order.

    "wrt" and "wrf" -> why this indicates t comes before f?

    If f came before t, then that list wouldn't be lexicographically sorted.


  • 0
    Y

    I originally had the same question as @gocha, then I realized that the sorting happens among the list of words, not within each word. Then the description makes sense.


  • 0
    G

    The line "You may assume that if a is a prefix of b, then a must appear before b in the given dictionary." Is throwing everyone off, including myself. It sounds as if it is talking about a word like "ab", when really I think it means that a and b are two separate words in the dictionary.


Log in to reply
 

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