Tap here to switch tabs
Problem
Submissions

Problem: Longest Harmonious Subsequence

med
30 min
Try to solve the Longest Harmonious Subsequence problem.

Statement

Given an integer array nums, return the length of the longest harmonious subsequence of nums.

A subsequence is formed by deleting zero or more elements from nums without changing the relative order of the remaining elements. A subsequence is called harmonious if the difference between its maximum value and minimum value is exactly 11.

If no harmonious subsequence exists, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤2⋅104\leq 2 \cdot 10^4

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Harmonious Subsequence

med
30 min
Try to solve the Longest Harmonious Subsequence problem.

Statement

Given an integer array nums, return the length of the longest harmonious subsequence of nums.

A subsequence is formed by deleting zero or more elements from nums without changing the relative order of the remaining elements. A subsequence is called harmonious if the difference between its maximum value and minimum value is exactly 11.

If no harmonious subsequence exists, return 00.

Constraints:

  • 1≤1 \leq nums.length ≤2⋅104\leq 2 \cdot 10^4

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9