Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2765. Longest Alternating Subarray
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.