Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Main(string[] args)
- {
- int[,] array = { { 4, 0, 1 },
- { 3, 4, 5 },
- { 3, 5, 5 }
- };
- int[] maxCount = new int[2];
- var countElems = new Dictionary<int, int>(array.GetLength(0));
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (!countElems.ContainsKey(array[i, j]))
- {
- countElems.Add(array[i, j], 1);
- }
- else
- {
- countElems[array[i, j]]++;
- }
- var maxSequence = countElems.Values.Max();
- if (maxCount[1] < maxSequence)
- {
- maxCount[0] = i;
- maxCount[1] = maxSequence;
- }
- }
- countElems.Clear();
- }
- Console.WriteLine(maxCount[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement