Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Zigzag Array by cnkisk
from typing import List
def create_zigzag(rows: int, cols: int, start: int = 1) -> List[List[int]]:
ans = []
for i in range(rows):
rev = -1 if i%2 else 1
ans.append(list(range(start + (cols*i), start + cols*(i+1)))[::rev])
return ans
June 9, 2021