Wiggle Subsequence
A medium-tier problem at 49% community acceptance, tagged with Array, Dynamic Programming, Greedy. Reported in interviews at Electronic Arts and 0 others.
Wiggle Subsequence shows up in live assessments and looks deceptively simple: find the longest subsequence where elements alternate between going up and down. The trap is that most candidates overthink it with DP, building tables and tracking states when a greedy scan solves it in linear time. It's a medium-difficulty problem with roughly 49% acceptance, which means half the people submitting it fail. Electronic Arts has asked this one. If you hit it cold during the OA and blank on the greedy pattern, StealthCoder runs invisibly and surfaces a working solution in seconds.
Companies that ask "Wiggle Subsequence"
Wiggle Subsequence is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe trick is understanding that you don't need to track subsequences explicitly. Instead, scan the array once, comparing consecutive non-equal elements, and count direction changes. Every time the direction flips (up to down or down to up), you've extended the wiggle. Many candidates build a DP table tracking 'up' and 'down' states, which works but wastes time and space. The greedy insight: any element that changes direction adds to the count, so you just need to detect sign flips in the differences. This problem teaches you when a greedy scan beats DP, which applies across harder array and sequence problems. If the greedy pattern doesn't click before your assessment, StealthCoder hedges the gap by showing the exact approach and implementation.
Pattern tags
You know the problem.
Make sure you actually pass it.
Wiggle Subsequence recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Wiggle Subsequence interview FAQ
Why does greedy work here when the problem asks for a subsequence?+
Greedy works because any direction change in the array creates a valid wiggle element. You're not constrained by adjacency or order rearrangement. Picking every element that creates a flip gives the longest possible result without needing DP.
What's the difference between this and Longest Increasing Subsequence?+
LIS requires monotonic direction; Wiggle requires direction to alternate. LIS typically needs DP. Wiggle's alternation pattern means a single greedy pass captures all direction changes, making it fundamentally simpler.
How hard is this really compared to other medium array problems?+
With 49% acceptance, roughly half of submissions fail. The difficulty comes from recognizing the greedy pattern and avoiding DP overkill. Once the insight clicks, it's a one-pass loop.
What are common mistakes on the live OA?+
Overthinking with DP when greedy suffices. Off-by-one errors in counting flips. Forgetting to skip equal consecutive elements. Mishandling the first valid direction flip in edge cases.
Does Electronic Arts ask follow-ups on this problem?+
Not confirmed from the interview data, but prepare to explain why greedy beats DP and discuss edge cases like all-equal arrays or length-two arrays.
Want the actual problem statement? View "Wiggle Subsequence" on LeetCode →