Is Unique

The task is to decide whether a string uses every character at most once. The answer is true when no character repeats anywhere in the string and false as soon as some character occurs a second time; the empty string and strings of length one are therefore always true.

The input is restricted to printable ASCII, codes 32 through 126, which means only 95 distinct characters can appear and a fixed-size table of 95 flags, or a 128-bit bitmap, is enough to track what has been seen. Scanning left to right and marking each character, then rejecting any character whose flag is already set, answers the question in a single pass with O(n) time and constant extra memory.

Alternative strategies trade memory for time. Sorting the characters first makes duplicates adjacent, so a linear scan over adjacent pairs decides the string, at O(n log n) time; that variant changes the input order unless the string is copied. A hash set is the straightforward O(n) time and O(k) space solution when the alphabet is not bounded. Interview variants often ask for the no-extra-structure version, which is where sorting or a bitmask of the allowed character range becomes relevant. Return a boolean, true for all-unique input.

Examples
Input: "abc"
Output: true
Hints

Is Unique

The task is to decide whether a string uses every character at most once. The answer is true when no character repeats anywhere in the string and false as soon as some character occurs a second time; the empty string and strings of length one are therefore always true.