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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count substrings with same first and last characters
- Count of Substrings that can be formed without using the given list of Characters
- Count distinct substrings that contain some characters at most k times
- Recursive solution to count substrings with same first and last characters
- Count number of substrings with exactly k distinct characters
- Count number of substrings of a string consisting of same characters
- Contiguous unique substrings with the given length L
- Queries for frequencies of characters in substrings
- Determine if a string has all Unique Characters
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Minimize number of unique characters in string
- String with maximum number of unique characters
- Longest substring with K unique characters using Binary Search
- Python program to check if a string contains all unique characters
- Find the longest substring with k unique characters in a given string
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.