Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NonRepeatingString
//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) { //nonRepeating("abcab"); // should return 'c' //nonRepeating("abab"); // should return null //nonRepeating("aabbbc"); // should return 'c' //nonRepeating("aabbdbc"); // should return 'd' Console.WriteLine(nonRepeating("aabbdbc")); } private static string nonRepeating(string input){ if( input == null ) return null; var charCount = new Dictionary<char, int>(); var charArray = input.ToCharArray(); for ( int i = 0; i < charArray.Length; i++ ) { if( charCount.ContainsKey(charArray[i]) ) charCount[charArray[i]] += 1; else charCount[charArray[i]] = 1; } foreach ( char c in input ) { if (charCount[c] == 1) return c.ToString(); } return null; } } }
run
|
edit
|
history
|
help
0
quadratics
Ejercicio 1 clase 8 feb
asxdf
domain extraction
Reverse And Shift Char in String
Get a webpage - the sync way
Lambda Expressions Are Cool 2
reverse words in astring
shell sort
knapsack