Posts

Showing posts with the label ascii

Why does 'Cracking The Coding Interview' advices to create an array chars[128]?

Image
Clash Royale CLAN TAG #URR8PPP Why does 'Cracking The Coding Interview' advices to create an array chars[128]? As far as I know, there are 65,535 chars in the Java language. Meanwhile, Unicode 11.0, contains a repertoire of 137,439 signs. I'm reading Cracking The Coding Interview and can't understand the internals of the present solution. Why does the book advice to create an array chars[128] in a case if String represents Unicode if there can be 137,439 Unicode signs? I'm not familiar with encoding, could you explain me it in details? Is Unique: Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? SOLUTION You should first ask your interviewer if the string is an ASCII string or a Unicode string. Asking this question will show an eye for detail and a solid foundation in computer science. We'll assume for simplicity the character set is ASCII. If this assumption is not valid, we would need ...