Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class LongestEqualSubsequence
- {
- static string[] array = { "D", "F", "G", "D", "F", "D", "A", };
- static void Main()
- {
- int appearance = 1, bestAppearance = 0;
- FindMostFrequant(appearance, bestAppearance);
- }
- static void FindMostFrequant(int appearance, int bestAppearance)
- {
- int value = 0;
- List<string> list = new List<string>();
- for (int i = 0; i < array.Length; i++)
- {
- if (list.Contains(array[i]))
- {
- continue;
- }
- for (int j = i + 1; j < array.Length; j++)
- {
- if (array[i] == array[j])
- {
- appearance++;
- if (bestAppearance < appearance)
- {
- bestAppearance = appearance;
- value = i;
- }
- }
- }
- appearance = 1;
- list.Add(array[i]);
- }
- Console.WriteLine("Best times -> " + bestAppearance);//3
- Console.WriteLine("Value -> " + array[value]);//D
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment