package com.算法专练.力扣.最大相等频率;
public static void main(String[] args) {
Solution solution = new Solution();
int[] nums = {2,2,1,1,5,3,3,5};
System.out.println(solution.maxEqualFreq(nums));
int[] cnt = new int[100010];
int[] sum = new int[100010];
public int maxEqualFreq(int[] nums) {
int n = nums.length, max = 0, ans = 0;
for (int i = 0; i < n; i++){
int t = nums[i], cur = ++cnt[t], len = i + 1;
// 注意,因为出现的次数加一了,那个上一个状态下出现的次数就应该减一。这样状态才能继续下去
max = Math.max(max, cur);
if (max * sum[max] + 1 == len){
if ((max - 1) * (sum[max - 1] + 1) + 1 == len){