#594
Longest Harmonious Subsequence
easy · 64.4% accepted · 2,826 likes · top 68%
array · hash table · sliding window · sorting · counting
Description
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1.
Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences.
Solution