in the test, my code can work right, but it tell me "确保显示的是连续序列的长度,而不是列表中重复次数最多的数字的总数", why?
package zh.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
最长序列
*/
public class Solution {
public static void main(String[] args) throws IOException {
//在此编写你的代码
ArrayList<Integer> list = new ArrayList<Integer>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (int i=0; i < 10; i++)
{
list.add(Integer.parseInt(br.readLine()));
}
int[] numbers = new int[10];
for (int i= 0; i < list.size() - 1; i++)
{
numbers[i] = 1;
if(list.get(i) != list.get(i+1))
{
numbers[i] = 1;
}
else if (list.get(i) == list.get(i+1)){
for (int j = i; j< list.size()-1; j++)
{
if (list.get(i) == list.get(j+1))
numbers[i] += 1;
}
}
}
int max = 0;
for (int i= 0; i < 10; i++)
{
if (i==0)
max = numbers[i];
if (max < numbers[i])
max = numbers[i];
}
System.out.println(max);
}
}