Maximize partitions such that no two substrings have any common character Last Updated : 26 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Try it on GfG Practice 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 Comment More infoAdvertise with us Next Article Maximize partitions such that no two substrings have any common character V vabzcode12 Follow Improve Article Tags : Strings Greedy Mathematical DSA substring +1 More Practice Tags : GreedyMathematicalStrings Similar Reads Maximize String Partitions with No Common Characters Given a string s consisting of lowercase English letters, partition s into the maximum number of substrings such that no two substrings share a common character. Return the total number of such substrings.Examples:Input: s = "acbbcc" Output: 2Explanation: "a" and "cbbcc" are two substrings that do n 13 min read Split a String into two Substring such that the sum of unique characters is maximum Given a string str, the task is to partition the string into two substrings such that the sum of unique characters of both substrings is the maximum possible. Examples: Input: str = "abcabcdâ Output: 7Explanation: Partition the given string into "abc" and "abcd", the sum of unique characters is 3 + 14 min read Longest substring such that no three consecutive characters are same Given string str, the task is to find the length of the longest substring of str such that no three consecutive characters in the substring are same.Examples: Input: str = "baaabbabbb" Output: 7 "aabbabb" is the required substring.Input: str = "babba" Output: 5 Given string itself is the longest sub 6 min read Maximize product of lengths of strings having no common characters Given an array arr[] consisting of N strings, the task is to find the maximum product of the length of the strings arr[i] and arr[j] for all unique pairs (i, j), where the strings arr[i] and arr[j] contain no common characters. Examples: Input: arr[] = {"abcw", "baz", "foo", "bar", "xtfn", "abcdef"} 12 min read Check if two strings have a common substring You are given two strings str1 and str2. You have to check if the two strings share a common substring. Examples : Input : str1 = "HELLO" str2 = "WORLD" Output : YES Explanation : The substrings "O" and "L" are common to both str1 and str2 Input : str1 = "HI" str2 = "ALL" Output : NO Explanation : B 5 min read Like