LeetCode test bug in the new version of Anagrams


  • 0
    C

    Just because the order is different, leetcode think it's wrong.

    Submission Result: Wrong Answer

    Input:
    ["tea","and","ate","eat","den"]

    Output:
    [["tea","ate","eat"],["and"],["den"]]

    Expected:
    [["den"],["and"],["ate","eat","tea"]]


  • 1

    You're clearly violating this clearly stated requirement:

    "Note:
    1.For the return value, each inner list's elements must follow the lexicographic order."

    Your ["tea","ate","eat"] isn't in lexicographic order.


  • 0
    C

    Thanks for pointing it out. So I just add Collections.sort(eachStringList), that requirement makes no sense at all.


  • 0
    Y

    Facing similar issue for Group Anagrams problem. Ordering given in problem description is different from expected answer and pattern is not clear. Also, Problem doesn't mentions lexicographic order currently.

    As per problem description:
    For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
    Return:
    [
    ["ate", "eat","tea"],
    ["nat","tan"],
    ["bat"]
    ]

    As per expected answer:
    Expected answer
    [["bat"],["ate","eat","tea"],["nat","tan"]]

    In expected answer, list with "ate" is 2nd while with "bat" is 1st. Also 1st list has 1 element, 2nd has 3 elements and 3rd has 2 elements.


  • 1

    @Yogesh Yes, it was changed recently. See how the problem still looked three months ago.


Log in to reply
 

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