Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- string sentence = Console.ReadLine();
- Dictionary<string, int> result = new Dictionary<string, int>();
- for(int i = 0; i < sentence.Count() - 1; i++)
- {
- char current = sentence.ElementAt(i);
- char next = sentence.ElementAt(i + 1);
- if(current == next)
- {
- string pair = current.ToString() + next.ToString();
- if(result.ContainsKey(pair))
- {
- result[pair]++;
- } else
- {
- result.Add(pair, 1);
- }
- }
- }
- var value = result.Values.Max();
- var key = result.Keys.Where(x => result[x] == value && x != " ").Min();
- Console.WriteLine(key);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement