Back to course home
0% completed
Vote For New Content
My solution
Mohammed Dh Abbas
Sep 20, 2024
class Solution: def maxUniqueSplit(self, s: str) -> int: def backtrack(s, seen, index): if index == len(s): return len(seen) max_split = 0 # from: index + 1 as we want to start from the index to --> any possible next character # to: len(s) + 1 because s[start: end] the syntax in not inclusive to the end for i in range(index + 1, len(s) + 1): substring = s[index: i] if substring not in seen: seen.add(substring) max_split = max(max_split, backtrack(s, seen, i)) seen.remove(substring) return max_split return backtrack(s, set(), 0)
0
0
Comments
Comments