Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
First Non repeat char
//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) { String str = "aaa b bdd h aaa k "; char ch = firstNonRepeatedChar(str); } public static char firstNonRepeatedChar(String str) { Dictionary<char,int> dict = new Dictionary<char,int>(); dict.Add(str[0],1); for(int i=1; i< str.Length; i++) { if(dict.ContainsKey(str[i])) dict[str[i]]++; else dict.Add(str[i],1); } foreach (KeyValuePair<char,int> keypair in dict) { if(keypair.Value==1) { Console.Write(keypair.Key); return keypair.Key; break; } } return ' '; } } }
run
|
edit
|
history
|
help
0
THRWSC SDXS
learning1
Testing 002
asxsdf
C# Events and Delegates example
Home work3 finding Min and Max (to theGit)
Print 2D Array
generic hierarchy1
sortowania przez wstawienie Correct
asfdfsafasfsa