Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int maxCount = 0;
- int maxStart = 0;
- int currentCount = 1;
- int currentStart = 0;
- for (int i = 1; i < array.Length; i++)
- {
- if (array[i]==array[i-1])
- {
- currentCount++;
- if (currentCount > maxCount) { maxCount = currentCount; maxStart = currentStart; }
- }
- else
- {
- currentCount = 1;
- currentStart = i;
- }
- }
- int[] result = array.Skip(maxStart).Take(maxCount).ToArray();
- Console.WriteLine(string.Join(" ", result));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement