Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Zigzag Array by rybld2
from typing import List
def create_zigzag(rows: int, cols: int, start: int = 1) -> List[List[int]]:
res = [[x + start + j * cols for x in range(cols)] for j in range(rows)]
res = [res[i] if i % 2 == 0 else sorted(res[i], reverse=True) for i in range(len(res))]
return res
June 15, 2021
Comments: