Meandering Array
Reported by candidates from Verisk's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Verisk reported this one in October 2026, and it's a clean array problem hiding behind a fancy name. Meandering Array asks you to rearrange numbers so they go largest, smallest, second largest, second smallest, and so on. The data structure that matters is the plain sorted array. Sort once, then walk two pointers inward from both ends. If you've got a Verisk OA coming and you're nervous about edge cases, this is a good one to see coming. StealthCoder sits invisibly on your screen as a safety net in case you blank mid-assessment.
The problem
An array of integers is defined as being in meandering order when the first two elements are the respective largest and smallest elements in the array and the subsequent elements alternate between its next largest and next smallest elements. In other words, the elements are in order of [first_largest, first_smallest, second_largest, second_smallest,...]. Function meanderingArray(unsorted: int[]) → int[] Complete the function meanderingArray in the editor below. meanderingArray has the following parameters: int unsorted[n]: the unsorted array Returns int[n]: the array sorted in meandering order Examples Example 1 unsorted = [-1, 1, 2, 3, -5] return = [3, -5, 2, -1, 1] The array [-1, 1, 2, 3, -5] sorted normally is [-5, -1, 1, 2, 3]. Sorted in meandering order, it becomes [3, -5, 2, -1, 1]. Constraints 2≤n≤10^5 -10^6 ≤ unsorted[i] ≤ 10^6 The unsorted array may contain duplicate elements.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to sort ascending, then place elements with two pointers. Start lo at 0 and hi at n-1. Alternate: take sorted[hi] and decrement, then take sorted[lo] and increment, until the output has n items. That's O(n log n) for the sort and O(n) for the build, which is fine for n up to 10^5. The common pitfalls are odd lengths and duplicates. With odd n, the last element comes from the largest side, and the pointers meet on it, so stop on count, not on pointer crossing. Duplicates need no special handling because you're working off sorted positions. Another mistake is mutating the input when the function should return a new array. If you freeze on the pointer loop during the live OA, StealthCoder can hand you the working version fast.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Meandering Array cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Verisk's OA.
Verisk reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Meandering Array FAQ
What's the trick to Meandering Array?+
Sort ascending, then fill the result by alternating between the high end and the low end with two pointers. Take from the high pointer first, then the low pointer. Repeat until you've filled n slots. That's the whole solution.
How hard is this problem really?+
Easy. The only real thinking is the pointer order and odd-length handling. If you know sorting and two pointers, you can write it in a few minutes. Most mistakes come from starting with the smallest instead of the largest.
How do I handle odd-length arrays?+
Loop by output index, not by comparing pointers. Even indexes take from the high pointer, odd indexes from the low pointer. With odd n, the final slot is an even index, so it takes the last remaining value from the high side. The example [-1,1,2,3,-5] ends on 1.
Do duplicates break anything?+
No. The constraints say duplicates can appear, but you're picking by position in the sorted array, not by unique value. Two equal values just occupy two slots. No set, no dedupe, no special cases.
How do I prepare for this in 48 hours?+
Write it twice from scratch. Test on an even-length array, an odd-length array, and one with all equal values. Know your language's sort and its complexity. Then spend the remaining time on other array and two-pointer problems, since this pattern repeats a lot.