A better approach is to use bit manipulation to set the value of passed character and xor the current one to check if current char exists or not in Constant space linear time complexity
The bit approach is more complex than using a hashmap and starts breaking down if the values aren't guaranteed to be ASCII. In fact, one can argue the hashmap solution is O(1) because the problem states only english letters, digits, symbols, and spaces are used. Therefore, the hashmap has a constant upper bound of keys, even in the worst case.
Hope this helps you understand the problem, happy hacking!
A better approach is to use bit manipulation to set the value of passed character and xor the current one to check if current char exists or not in Constant space linear time complexity
The bit approach is more complex than using a hashmap and starts breaking down if the values aren't guaranteed to be ASCII. In fact, one can argue the hashmap solution is O(1) because the problem states only english letters, digits, symbols, and spaces are used. Therefore, the hashmap has a constant upper bound of keys, even in the worst case.