![]() |
VOOZH | about |
Given string str, the task is to split the string into the maximum number of unique substrings possible and print their count.
Examples:
Input: str = "ababccc"
Output: 5
Explanation:
Split the given string into the substrings "a", "b", "ab", "c" and "cc".
Therefore, the maximum count of unique substrings is 5.Input: str = "aba"
Output: 2
Approach: The problem can be solved by the Greedy approach. Follow the steps below to solve the problem:
Below is the implementation of the above approach:
5
Time Complexity: O()
Auxiliary Space: O(N)