Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Max occured character in a string
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Console.WriteLine(MostOccurringCharInString("aaaacffffdgg")); } public static char MostOccurringCharInString(string charString) { int mostOccurrence = -1; char mostOccurringChar = ' '; foreach (char currentChar in charString) { int foundCharOccreence = 0; foreach (char charToBeMatch in charString) { if (currentChar == charToBeMatch) foundCharOccreence++; } if (mostOccurrence < foundCharOccreence) { mostOccurrence = foundCharOccreence; mostOccurringChar = currentChar; } } return mostOccurringChar; } } }
run
|
edit
|
history
|
help
0
What is the best way to iterate over a Dictionary in C#?
масиви форіч
eryjuyhtgrfesdsadcfg
XmlSerializer
DateTime With TimeZone to UTC DateTime
Non Generic object based class
sulu
Armstrong
asfdfsafasfsa
Fusion