【Max】今天接还是明天接,请小咪妈土拨鼠来看update# pets - 心有所宠
h*o
1 楼
Given a string s, partition s such that every substring of the partition is
a palindrome. Return all possible palindrome partitioning of s.
For example, given s = "aab", Return
[
["aa","b"],
["a","a","b"]
]
知道是用backtracking + DP. 但只知道判断是否Palindrome 可以DP. 不知道为何有贴
说有两个地方可以DP?
复杂度如何求?
time: 每个node 分成 n 支, 有n 层树, 难道 是 time = n^n?
space: n (recursive)+ n^2 (存 isPalindrome 的结果) = n^2?
a palindrome. Return all possible palindrome partitioning of s.
For example, given s = "aab", Return
[
["aa","b"],
["a","a","b"]
]
知道是用backtracking + DP. 但只知道判断是否Palindrome 可以DP. 不知道为何有贴
说有两个地方可以DP?
复杂度如何求?
time: 每个node 分成 n 支, 有n 层树, 难道 是 time = n^n?
space: n (recursive)+ n^2 (存 isPalindrome 的结果) = n^2?