# sorting advanced

The Perfect Zigzag

The dance line must zigzag: up, down, up, down β€” every step changes direction, no repeats in a row. πŸ’ƒ

You get at least 2 nums with no equal neighbors. Print zigzag if the direction flips at every step (it may start going either up or down), otherwise no zigzag.

Example:

Input: nums = [1, 5, 2, 6, 3] Output: zigzag

The direction flips every step β€” up (1β†’5), down (5β†’2), up (2β†’6), down (6β†’3) β€” never repeating.

πŸ’‘ need a hint?

sort-perfect-zigzag.pyπŸ”’ given lines are locked β€” write your code in between
loading...