I am working through the book \"Cracking the Coding Interview\" and I have come across questions here asking for answers, but I need help comparing my answer to the solution
The solution from the book is case insensitive. 'A' and 'a' is considered duplicate as per the implementation.
Explanation: for input string with char 'A', 'A' - 'a' is -32 so '1 << val' will be evaluated as 1 << -32. shift on any negative number will shift the bits in opposite direction. thus 1 << -32 will be 1 >> 32. Which will set the first bit to 1. This is also the case with char 'a'. Thus 'A' and 'a' are considered duplicate characters. Similarly for 'B' and 'b' second bit is set to 1 and so on.