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