pub fn condense(str: &str) -> StringExpand description
Removes all duplicate characters from a string, preserving the first occurrence of each.
This function iterates through the input string and builds a new string containing only
the first occurrence of each character, maintaining the original order. It uses a HashSet
to track which characters have already been encountered.
§NOTE
This is an alternate version using the ahash crate abd its AHashSet instead of the std one.
§Performance
Time complexity: O(n) where n is the length of the input string Space complexity: O(k) where k is the number of unique characters
§See Also
condense_str- An optimized version using a bitset for ASCII characters