I have some question about the answer when numRows is 2


  • 0
    E

    Sorry my English is not so well. I'm a noob Chinese.
    So maybe this article is hard to understand. Forgive me plz.
    I think a string convert to ZigZag pattern is like .... eh.. how to describe...
    Like this, string is 'abcdef' and numRows is 4
    First, ZigZag pattern's first col is a b c d from top to bottom like this:
    a
    b
    c
    d
    and then the second col is e f from bottom to top.
    a
    b f
    c e
    d
    But when numRows is 2
    The answer is acebdf... it means the pattern is
    a c e
    b d f
    But i think it should be
    a d e
    b c f

    So who can tell me why?
    (F**k i think i write a piece of shit... Sorry)


  • 0
    M

    Your writing is not terrible. The way I understand it is the zig zag pattern does not look like

    \  /\
     \/  \
    

    It looks more like

    | /| /
    |/ |/

    Also, I think what you are describing with the
    a d e
    b c f

    is more like a square wave pattern, which does not fit in this instance.

    Hope this helps!


  • 0
    E

    @mikjay
    First, thank you very much.
    And i think i get what you say.
    When numRows is 2,
    the pattern is only
    | |
    | |,
    the part of / is not in pattern, right?
    So it is
    a c
    b d
    When numRows > 2, then the pattern is
    | / |
    | / | like this.
    Emmm....
    I think i have understood it.

    Thank you and Thank you very much!


Log in to reply
 

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