Last active
August 29, 2015 14:22
-
-
Save billpratt/ea3f0a91734d84c930e4 to your computer and use it in GitHub Desktop.
Return the most common character that appears first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static char FirstMostCommonCharacter(string text) | |
{ | |
return text | |
.GroupBy(c => c) | |
.OrderByDescending(c => c.Count()) | |
.Where(c => c.Key != ' ') // dont include white space | |
.Select(c => c.Key) | |
.FirstOrDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment