Available question text
Find the longest contiguous subarray (length > 1) whose consecutive differences alternate +1, -1, +1, ... — i.e., each element toggles between prev+1 and prev-1 starting with +1. Return its length or -1 if no such subarray exists.
Related questions
Continue with questions that share topics or the same question type.
- Find the Longest Equal Subarray
Coding
- Length of Longest Subarray With at Most K Frequency
Coding
- Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
Coding · Array · Heap (Priority Queue) · Monotonic Queue
- Longest Even Odd Subarray With Threshold
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2765. Longest Alternating Subarray
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source