For custom input: vzdavv
Solution should be 2 =[v z d a v v, v z d a vv] as shown in the Palindrome partitioning problem
However, the solution shows 0 here
any python solution?
func partition2(s string) int {
dp := make([]int, len(s)+1)
dp[0] = 1
for i := 1; i <= len(s); i++ {
for j := 0; j < i; j++ {
if isPalindrome(s[j:i]) { dp[i] += dp[j] }
}
}
return dp[len(s)]
}
func isPalindrome(s string) bool {
for i:= 0; i < len(s)/2; i++ {
if s[i] != s[len(s)-1-i] { return false }
}
return true
}
Is the scorer correct? input “abc” should return 1: a|b|c, but expected output says 0
This page nees several fixes in the solution description and also in the code comments
This problem and solution need fix.
For example, test case 2 dfxferlmjz, only fxf is palindrome, but the expected output says “2”. Don’t get it.
Test case 1: aab, palindrome is either a|a|aa|b, or aa only, but the expected output also says “2”.