You are given an integer array nums.
Define a frequency balance subarray as follows:
f such that every distinct value in the subarray occurs either f or 2 * f times, and both frequencies occur among the distinct values.Return an integer denoting the length of the longest frequency balance subarray.
Example 1:
Input: nums = [1,2,2,1,2,3,3,3]
Output: 5
Explanation:
[2, 1, 2, 3, 3].Example 2:
Input: nums = [5,5,5,5]
Output: 4
Explanation:
[5, 5, 5, 5].Example 3:
Input: nums = [1,2,3,4]
Output: 1
Explanation:
Since all elements appear only once, the length of the longest frequency balance subarray is 1.
Constraints:
1 <= nums.length <= 1031 <= nums[i] <= 109Loading editor...
[1,2,2,1,2,3,3,3]