All Characters Unique
Practice All Characters Unique for free on NudgeCode: Easy, Bit Manipulation pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given a string s whose character codes are all between 0 and 255, return true if no character appears twice and false otherwise. Don't use a set or a hash map; a 256-bit mask (or a few integers used as one) is enough.
Example
s = "abc" -> true
s = "aba" -> false
The empty string has no repeated character, so it returns true.
Constraints
- 0 <= s.length <= 10^4
- every character code is in [0, 255]