Group shifted Strings - Wrong expected


  • 1
    F

    Input:
    ["ab","ba"]

    Output:
    [["ab","ba"]]

    Expected:
    [["ba"],["ab"]]

    My code submission is failing with the message above. As far as I can see, the expected result is incorrect. If not, can someone please explain to me why that's the case. Thanks.


  • 0

    The shifts of "ab" are "bc", "cd", "de", etc. Not "ba".


  • 0
    F

    The example given as part of the question -

    For example, given: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],

    Return:

    [
    ["abc","bcd","xyz"],
    ["az","ba"],
    ["acef"],
    ["a","z"]
    ]

    How are the shifts of az, ba?


  • 0

    'a' shifts to 'b', and 'z' shifts to 'a'. That example shows that the alphabet is apparently considered to wrap around here.


Log in to reply
 

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