Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Latest commit

 

History

History
23 lines (14 loc) · 583 Bytes

Zigzag_Traverse.md

File metadata and controls

23 lines (14 loc) · 583 Bytes

Zigzag Traverse

Problem Statement

Write a function that takes in a two-dimensional array and returns a one-dimensional array of all the array's elements in zigzag order. Zigzag order starts at the top left corner of the two-dimensional array, goes down by one element, and proceeds in a zigzag pattern all the way to the bottom right corner.

Sample input: [ [1, 3, 4, 10], [2, 5, 9, 11], [6, 8, 12, 15], [7, 13, 14, 16], ] Sample output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]

Solution

Check this Python code.