Problem with one test case [2,1,4,3,6,5,7,8]

  • 0

    Problem with one test case. I think the expected line is wrong.

    Input: [2,1,4,3,6,5,7,8]
    Output: [2,4,6,8,1,3,5,7]
    Expected: [2,4,6,7,1,3,5,8]

  • 0

    @leet444 If the input you've listed denotes values, the expected line is correct.

    If we make the following variable substitution:
    input = [2, 1, 4, 3, 6, 5, 7, 8]
    input = [A, B, C, D, E, F, G, H]

    Then our expected is [A, C, E, G, B, D, F, H], since we're linking every "odd" element, followed by every "even" element.

    As the Problem Statement notes:

    The first node is considered odd, the second node even and so on ...

    If we reverse the substitutions above, we arrive at an expected of [A=2, C=4, E=6, G=7, B=1, D=3, F=5, H=8].

Log in to reply

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