1. Hash map initialization is like this:
HashMap<K, V> map = new HashMap<K, V>();
K,V can only be class type, not primitive. So when you want to use int or char, use Integer and Character instead.
Converting from int to Integer: new Integer(i); Integer -> int: Integer.intValue()
Converting from char to Character: new Character(c); Character -> char: Character.charValue();
It seems now java will automatically convert for you.
tips: HashMap uses too much spaces. Change to array of boolean, boolean[] checker[i] (i is the int value of char)
2. details
(1) unicode or ascii code
(2) if it is ascii code, it only has 256 chars. So if the string length is larger than 256, return false directly
(3) what if the given string is null or empty? Deal with it in your code
3. bit implementation
(1) byte 8, short 16, int 32, long 64, char 16
(2) use BitSet, set ith bit to indicate that char i has appeared before
(3) use bit manipulation. When char appears, change the ith bit to 1(i = the int value of char)
4. if do not use additional data structure
(1) if allowing to modify string, sort it.
(2) if not allow, naively brute force o(n^2)
tips: string is immutable in java, use StringBuilder instead. StringBuilder is faster than StringBuffer, because StringBuilder is not synchronized