Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class LongestEqualSubsequence
- {
- static void Main()
- {
- string someText = "AASDDSDASD";
- FinsMostFrequant(someText);
- }
- static void FinsMostFrequant(string someText)
- {
- int len = 1, bestLen = 0;
- char value = ' ';
- List<int> list = new List<int>();
- for (int i = 0; i < someText.Length; i++)
- {
- if (list.Contains(someText[i]))
- {
- continue;
- }
- char firstEl = someText[i];
- for (int g = i + 1; g < someText.Length; g++)
- {
- if (firstEl == someText[g])
- {
- len++;
- if (len > bestLen)
- {
- bestLen = len;
- value = someText[i];
- }
- }
- }
- len = 1;
- list.Add(someText[i]);
- }
- Console.WriteLine("Best times -> " + bestLen);
- Console.WriteLine("Value -> " + value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment