Reorder array in alternating peaks and valleys
Filed under Thoughtworks
The question
Given an array of integers, rearrange the elements such that they alternate between local peaks and valleys.
No write-up yet. Related questions below have one.
Related Thoughtworks questions
Collected from public candidate posts and coding forums. Updated Nov 2026.