Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaxSequenceOfEqualElements
- {
- static void Main()
- {
- int[] arr = { 2, 1, 1, 2, 3, 3, 2, 2, 2, 1 };
- int start = 0;
- int len = 1;
- int bestStart = 0;
- int bestLen = 1;
- for (int i = 0; i <= arr.Length - 1; i++)
- {
- if (arr[i + 1] == arr[i])
- {
- len++;
- if (bestLen<len)
- {
- bestLen = len;
- bestStart = start;
- }
- }
- else
- {
- start = i + 1;
- len = 1;
- }
- }
- for (int n = bestStart; n < bestStart + bestLen; n++)
- {
- Console.WriteLine(arr[n]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement