Given a string str consisting of lowercase characters, the task is to find the total numbers of unique substrings with non-repeating characters.
Input: str = “abba”
There are 4 unique substrings. They are: “a”, “ab”, “b”, “ba”.
Input: str = “acbacbacaa”
Approach: The idea is to iterate over all the substrings. For every substring, check whether each particular character has previously occurred or not. If so, then increase the count of required substrings. In the end return this count as count of all unique substrings with non-repeating characters.
Below is the implementation of the above approach:
Time Complexity: O(N2) where N is the length of the string.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count of substrings having all distinct characters
- Count of substrings of a given Binary string with all characters same
- Count number of substrings with exactly k distinct characters
- Count substrings with same first and last characters
- Recursive solution to count substrings with same first and last characters
- Count distinct substrings that contain some characters at most k times
- Count number of substrings of a string consisting of same characters
- Count of Substrings that can be formed without using the given list of Characters
- Count of substrings of length K with exactly K distinct characters
- Count of substrings formed using a given set of characters only
- Count of Substrings with at least K pairwise Distinct Characters having same Frequency
- Count substrings with different first and last characters
- Contiguous unique substrings with the given length L
- Minimum number of operations to move all uppercase characters before all lower case characters
- Efficiently check if a string has all unique characters without using any additional data structure
- Determine if a string has all Unique Characters
- Python program to check if a string contains all unique characters
- Count ways to split a Binary String into three substrings having equal count of zeros
- Count the number of vowels occurring in all the substrings of given string
- Count all Prime Length Palindromic Substrings
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.