What k lists should produce... (?)


  • 1

    I'm not sure what the result for k lists should be. For

    [1,2,3]
    [4,5,6,7]
    [8,9]
    

    I find it clear that it should be [1,4,8,5,2,6,9,7,3] because that looks like this:

    [1,      2,      3]
    [  4,  5,  6,  7  ]
    [    8,      9    ]
    

    You can also compare it to the first zigzag problem and this nice explanation for it.

    (Btw, kudos to WalkerIX for being first to point out that cycling isn't zigzagging.)

    But what about this:

    [1,2,3]
    [4,5,6,7]
    [8]
    

    I see two possibilities:

    Keep zigzagging the original lists, producing [1,4,8,5,2,6,7,3]:

    [1,      2,      3]
    [  4,  5,  6,  7  ]
    [    8       -    ]
    

    Keep zigzagging the remaining lists, producing [1,4,8,5,2,6,3,7]:

    [1,      2,  3]
    [  4,  5,  6,  7]
    [    8]
    

    Thoughts?


  • 0

    Oh, after reading your posts. I guess I may have misunderstood zigzag. In fact, my original answer to your first example is [1, 4, 8, 2, 5, 9, 3, 6, 7]:

    [1,         2,         3]
    [    4,         5,         6, 7]
    [        8,         9]
    

    Oh, this is far too easier and certainly not zigzagging...


  • 0

    Sorry for the ambiguous description in the problem statement.

    For k > 2 cases, the "zigzag" order is not clearly defined and is ambiguous. I have just updated the problem description. For your example, it should return [1,4,8,2,5,9,3,6,7].


  • 0

    But that's really not zigzag. Zigzag is going forth and back, forth and back, alternating directions, without jumping. Have a look at Wikipedia, Google images, or even the previous two zigzag problems right here on LeetCode. Is it too late to change the name of the problem?


  • 0

    I agree zigzag is not the correct name. I can change the name. What name do you suggest, Stefan?


  • 0

    I think "Round-Robin Iterator" would be good. Or "Cyclic Iterator". Though Round-Robin sounds nicer and already suggests that there are several things and that we're going through each of them ("cyclic" could refer to cycling through a single 1d-vector).


Log in to reply
 

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