By hand calculation is different


  • 0
    T

    I have this input

    "012345"
    5
    

    By hand, I drew this:

    0
    1 5
    2
    3 
    4
    

    and the result should be

    015234
    

    but the expected value came back as

    012354
    

    I think, what was drawn was:

    0
    1 
    2
    3 5
    4
    

    Can anyone help me understand why 5 is next to 3 and not next to 1?

    Thanks.


  • 0
    S

    @ttwd80

    ZigZag Pattern should be as follows

    00-XX-XX-XX-XX-XX-12
    01-XX-XX-XX-XX-11-13
    02-XX-XX-XX-10-XX-14
    03-XX-XX-09-XX-XX-15
    04-XX-08-XX-XX-XX-16
    05-07-XX-XX-XX-XX-17
    06-XX-XX-XX-XX-XX-18

    where XX is a blank space.

    Thus the output should be
    00-12-01-11-13-02-10-14-03-09-15-04-08-16-05-07-17-06-18


Log in to reply
 

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