Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 594. Longest Harmonious Subsequence
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).
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.