Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- String[] numberStrs = scanner.nextLine().split(" ");
- int[] numbers = new int[numberStrs.length];
- for(int i = 0;i < numberStrs.length;i++)
- {
- numbers[i] = Integer.parseInt(numberStrs[i]);
- }
- int maxStreakCounter = 0;
- int maxStreakNumber = 0;
- int internalCounter = 0;
- for (int i = 0; i < numbers.length;i++) {
- if (i < numbers.length - 1) {
- if(numbers[i] == numbers[i+1]) {
- internalCounter++;
- if (internalCounter > maxStreakCounter) {
- maxStreakCounter = internalCounter;
- maxStreakNumber = numbers[i];
- }
- } else {
- internalCounter = 0;
- }
- } else {
- String result = "";
- for (int j = maxStreakCounter; j >= 0; j--) {
- result += String.valueOf(maxStreakNumber) + " ";
- }
- System.out.print(result.substring(0,result.length()- 1));
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement