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.
2 parents f848b4f + 0cfe551 commit 60eef74Copy full SHA for 60eef74
problems/0647.回文子串.md
@@ -267,6 +267,27 @@ class Solution {
267
return ans;
268
}
269
270
+
271
+```
272
273
+动态规划:简洁版
274
+```java
275
+class Solution {
276
+ public int countSubstrings(String s) {
277
+ boolean[][] dp = new boolean[s.length()][s.length()];
278
279
+ int res = 0;
280
+ for (int i = s.length() - 1; i >= 0; i--) {
281
+ for (int j = i; j < s.length(); j++) {
282
+ if (s.charAt(i) == s.charAt(j) && (j - i <= 1 || dp[i + 1][j - 1])) {
283
+ res++;
284
+ dp[i][j] = true;
285
+ }
286
287
288
+ return res;
289
290
+}
291
```
292
293
中心扩散法:
0 commit comments