Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Concurrent;
- using System.Linq;
- namespace Arrays_tries_EndMarch
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- //.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
- char[] sep = { ' ' };
- var input = Console.ReadLine();
- // int num = int.Parse(Console.ReadLine());
- int[] arr = input
- .Split(sep, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int repeatedValue = arr[0];
- var longestCount = 1;
- var currentCount = 1;
- for (int i = 0; i < arr.Length - 1; i++)
- {
- var currentValue = arr[i];
- var nextValue = arr[i + 1];
- if(currentValue == nextValue)
- {
- currentCount++;
- if(currentCount > longestCount)
- {
- repeatedValue = nextValue;
- longestCount = currentCount;
- }
- }
- else
- {
- currentCount = 1;
- }
- }
- for (int a = 1; a <= longestCount; a++)
- {
- Console.Write("{0}", repeatedValue);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement