#594

Longest Harmonious Subsequence

pupil · 345 · lc easy +22 · 64.4% accepted · 2,826 likes · top 68%

play →

Description

A harmonious array has the property that the difference between its largest and smallest elements equals exactly 1. Given an integer array nums, return the length of the longest harmonious subsequence that can be formed from its elements.

Code

1
2
3