2716. Minimize String Length¶ Time: $O(n)$ Space: $O(n)$ C++JavaPython 1 2 3 4 5 6class Solution { public: int minimizedStringLength(string s) { return unordered_set(s.begin(), s.end()).size(); } }; 1 2 3 4 5class Solution { public int minimizedStringLength(String s) { return new HashSet<>(Arrays.asList(s.split(""))).size(); } } 1 2 3class Solution: def minimizedStringLength(self, s: str) -> int: return len({*s})