1593. Split a String Into the Max Number of Unique Substrings
Содержание
class Solution:
def maxUniqueSplit(self, s: str) -> int:
def dfs(i, t):
if i >= len(s):
nonlocal res
res = max(res, t)
return
for j in range(i + 1, len(s) + 1):
if s[i:j] not in vis:
vis.add(s[i:j])
dfs(j, t + 1)
vis.remove(s[i:j])
vis = set()
res = 1
dfs(0, 0)
return res