![]() |
VOOZH | about |
Given string s of size n, the task is to print the number of substrings formed after maximum possible partitions such that no two substrings have a common character.
Examples:
Input : s = "ababcbacadefegdehijhklij"
Output : 3
Explanation: Partitioning at the index 8 and at 15 produces three substrings "ababcbaca", "defegde" and "hijhklij" such that none of them have a common character. So, the maximum partitions are 3.Input: s = "aaa"
Output: 1
Explanation: Since, the string consists of a single character, no partition can be performed.
We have discussed three different approaches to solve this problem in Maximize String Partitions with No Common Characters