We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e41f6a8 commit 2249138Copy full SHA for 2249138
1745-palindrome-partitioning-iv.js
@@ -47,6 +47,31 @@ function manacher(s) {
47
return ans;
48
}
49
50
+// another
51
+
52
+/**
53
+ * @param {string} s
54
+ * @return {boolean}
55
+ */
56
+const checkPartitioning = function (s) {
57
+ const n = s.length
58
+ const dp = Array.from({ length: n }, () => Array(n).fill(false))
59
+ for(let i = n - 1; i >= 0; i--) {
60
+ for(let j = i; j < n; j++) {
61
+ if(s[i] === s[j]) {
62
+ dp[i][j] = i + 1 <= j - 1 ? dp[i + 1][j - 1] : true
63
+ } else dp[i][j] = false
64
+ }
65
66
+ for(let i = 1; i < n - 1; i++) {
67
+ for(let j = i; j < n - 1; j++) {
68
+ if(dp[0][i - 1] && dp[i][j] && dp[j + 1][n - 1]) return true
69
70
71
+ return false
72
+}
73
74
75
// another
76
77
/**
0 commit comments