[LeetCode] Longest Harmonious Subsequence 最长和谐子序列

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Longest Harmonious Subsequence 最长和谐子序列相关的知识,希望对你有一定的参考价值。

 

We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.

Now, given an integer array, you need to find the length of its longest harmonious subsequence among all its possible subsequences.

Example 1:

Input: [1,3,2,2,5,2,3,7]
Output: 5
Explanation: The longest harmonious subsequence is [3,2,2,2,3].

 

Note: The length of the input array will not exceed 20,000.

 

s

 

以上是关于[LeetCode] Longest Harmonious Subsequence 最长和谐子序列的主要内容,如果未能解决你的问题,请参考以下文章

leetcode:longest words

Leetcode409. Longest Palindrome

leetcode:longest-increasing

[Leetcode]Longest Palindromic Substring

leetcode longest consecutive sequence

LeetCode Longest Increasing Subsequence