Suppose you are given a string. How will you find whether a it has all unique characters in it.
< Using additional buffer > Let us assume that the input string has the character set ASCII.
Time complexity = \( O(n) \), space complexity = \( O(n) \). If the character set in the string has UNICODE instead of ASCII, we can apply the above algorithm increasing the size of the boolean array accordingly. public static boolean doesStringHasAllUniqueChars(String string) { < Without using additional buffer > We can solve the problem without using \( O(n) \) space complexity by using a bit vector. For simplicity, we are assuming that the input string has only lower case characters from 'a' to 'z'. public static boolean doesStringHasAllUniqueChars(String string){ |