8ms Java Solution based on ZigZag pattern (level by level traversal)

The pattern is like this, take rows=4, the first row and last row will have one step of 6 ( 6 is the max step here, computed by 2*(4-1) ), then in between the rows, there are two segments, each with firstStep ( 6-2i) and secondStep (2i), where i is the row index.