Created
March 11, 2015 19:58
-
-
Save rcurtis/92522da080c02594586f to your computer and use it in GitHub Desktop.
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 string Reverse(string input) | |
{ | |
var builder = new StringBuilder(input.Length); | |
for (var i = input.Length - 1; i >= 0; i--) | |
{ | |
builder.Append(input[i]); | |
} | |
return builder.ToString(); | |
} | |
public static string CountOccurence(string input) | |
{ | |
var bookKeeper = new Dictionary<char, int>(); | |
foreach (var character in input) | |
{ | |
if (bookKeeper.ContainsKey(character)) | |
bookKeeper[character]++; | |
else | |
bookKeeper.Add(character, 1); | |
} | |
var builder = new StringBuilder(); | |
foreach (var pair in bookKeeper) | |
{ | |
builder.AppendFormat("{0}: {1}, ", pair.Key, pair.Value); | |
} | |
return builder.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment