Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BiggestSequence {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numb = scanner.nextInt();
- int[] sequence = new int[numb];
- for (int i = 0; i < sequence.length; i++) {
- sequence[i] = scanner.nextInt();
- }
- int counter = 1;
- int max = Integer.MIN_VALUE;
- for (int j = 0; j < sequence.length; j++) {
- if (j != 0) {
- if (sequence[j - 1] == sequence[j]) {
- counter++;
- if (counter >= max) {
- max = counter;
- }
- } else {
- counter = 1;
- }
- }
- }
- System.out.println(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment