Wrong answer for input size 2


  • 0
    Y

    I just want to clarify the output
    for n = 3, the example output is:
    [
    [1,2,3]
    [8,9,4]
    [7,6,5]
    ]

    seems the output is in clock-wise spiral sequence.

    however when input is 2, the output is:
    [
    [1,4]
    [2,3]
    ]
    which is counter clock-wise.
    Could anybody tell me what the final output format is?
    Thanks!


  • 0
    S

    It is always clock-wise.
    Here is the expected result for n = 2, Expected: [[1,2],[4,3]].

    I believe it would be some misreading about the submission results.


  • 0
    Y

    Here is the output on my local IDE:

    matrix size is: 1
    [1]

    matrix size is: 2
    [1][2]
    [4][3]

    matrix size is: 3
    [1][2][3]
    [8][9][4]
    [7][6][5]

    matrix size is: 4
    [1][2][3][4]
    [12][13][14][5]
    [11][16][15][6]
    [10][9][8][7]

    matrix size is: 5
    [1][2][3][4][5]
    [16][17][18][19][6]
    [15][24][25][20][7]
    [14][23][22][21][8]
    [13][12][11][10][9]

    According to the online judge, when input 2, output is depicted as [[1,4],[2,3]] which seems to be counter clock-wise.
    Anything we can do to change the judge result?


  • 0
    M

    My code gives [[1,4],[2,3]] on my local IDLE and it is accepted by the OJ. So I think either you misunderstand the information given by the OJ, or OJ gives the wrong information while the test is still correct. I also spotted that your output format is weird. for n=2, the result should be [[1,4],[2,3]], but not [1][2] [4][3],


Log in to reply
 

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