Skip to main content
8 events
when toggle format what by license comment
Aug 7, 2014 at 12:02 comment added mjolka @EmanuelePaolini it is \$O(n)\$. Chars in .NET are 16 bits though, so you would need an array of size 65,536, which makes the dictionary a better option.
Aug 7, 2014 at 11:55 comment added Emanuele Paolini The dictionary implementation seems to be \$O(n)\$ if the dictionary is implemented as an hashtable. In fact one could use a fixed array of size 256 instead of the dictionary.
Aug 7, 2014 at 11:18 comment added Recipe Don't forget that this code will not check for uppercase / lowercase characters, as well as foreign characters (eg. ñ != n). You could replace the s1Sorted == s2Sorted with s1Sorted.Equals(s2Sorted, StringComparison)
Aug 7, 2014 at 11:15 comment added mjolka @Pimgd thank you, I don't know what I was thinking.
Aug 7, 2014 at 11:15 history edited mjolka CC BY-SA 3.0
I'm an idiot
Aug 7, 2014 at 11:14 comment added Pimgd Why bother with a for loop for comparing strings character by character? Can't you simply use a string equals function?
Aug 7, 2014 at 11:08 history edited mjolka CC BY-SA 3.0
Add missing return
Aug 7, 2014 at 10:45 history answered mjolka CC BY-SA 3.0