Dude, LINQ is a such wonderful feature of this language.
I used it only partially in my solution, but this is so hot, have to learn it better.
wow,the first time write the same code.
Select(x => x - 'a'+1) // What is the logic here Please help me to understand
This happens because you can't downvote some solutions.
Duplicate issue below
Most efficient and performant solution.
Definitely Best Practice, even though it is clever in its own unique way.
@pescadomuerto: when it comes to time complexities, most of the time comparing the number of passes is meaningless. You're currently sort of saying that 3*n != n*3. That's why the asymptotic behavior is ignoring the constant factors.
3*n != n*3
RoFTW, for a HashSet, Contains() is an O(1) operation, not O(N). So there is no "going over the set" in my solution. Also, using exception handling (try/catch) as in your solution will have comparitively terrible performance as setting up and triggering exceptions is very, very expensive. So while your solution is O(N), the c is very very large in practice. The perf overhead of exception handling is why there are often versions of the same operations that do not throw exceptions in some class libraries, like TryParse, TryGetValue, etc.
Your solution goes over the set for each iteration of the for loop - this means in the worst case scenario it is O(n^2).
It's the base of the return value. As binary is requested it is 2. But 8, 10 and 16 are also possible.
What exactly does the 2 do in this code?
Char.IsLetter is unreliable, look at the doc, you will get Cyrillic, Greek, Hebrew, Arabic, Chinese...
String.ToLower is unreliable, it's by local, String.ToLowerInvariant should be used instead.
E.g. in Turkish, the lower case of 0049 I latin capital letter I is 0131 ı latin small letter dotless i.
0049 I latin capital letter I
0131 ı latin small letter dotless i
You get used to them when you start using them.