For those who are not familiar with ASCII characters.
ASCII abbreviation is known as American Standard Code for Information Interchange.
In simple words it is just the number representation of characters.
So , First understand the question by writing examples :
Input : Alive is awesome
Output : false
Input : Live present moment
Output : false
Input : Alive swum
PseudoCode for Method 1 :
1. Create a HashSet object.
2. Scan the whole string, and add each character one by one to the HashSet object
3. If the add object returns true then continue
else return false
PseudoCode for Method 2 :
1. Scan the input string , take each character one by one and set count flag to 0.
2. For each character in the inputstring ,Rescan the inputstring and compare the character with each character appear in the inputstring
3. If equal then increase the count by 1
else continue the loop
4. If count flag value is greater than 1 then return false
else return true
PseudoCode for Method 3:
1. indexOf() returns the index of first occurence of the character or else return -1. So , here we are creating an arraylist object.
2. Scan the inputstring and add the index of each character to the arraylist object.
3. Sort the arraylist object.
4. Compare the values of each adjacent positions of arraylist object
if equal then return false
else continue scanning the arraylist
5. return true
PseudoCode for Method 4 :
1. For this method we need to know about two inbuilt functions in java , indexOf() which returns the index of first occurence of the character in the string , while second function lastIndexOf() returns the index of last occurence of the character in the given string.
2. First , we convert the given inputstring into characterarray by using toCharArray() function.
3. Calculate the indexOf() and lastIndexOf() for each character in the given inputstring
4. If both are equal then continue and make result= true
else set flag result = false
5. Return result
Most memory efficient answer
Please mention in the comments what is the time complexity of each of the above method and why ?
Also write in comments if you have any other method to find all the unique characters in string.