Available question text
Find the length of the longest subsequence whose elements differ by exactly 1 (i.e., all elements are either x or x+1 for some x). This reduces to counting frequencies and returning the maximum sum freq[x] + freq[x+1] over all values x (or 0 if no such pair exists).
Related questions
Continue with questions that share topics or the same question type.
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 594. Longest Harmonious Subsequence
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source