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 61cc513 commit c8ec385Copy full SHA for c8ec385
1 file changed
palindromic-substrings/chjung99.go
@@ -0,0 +1,24 @@
1
+func countSubstrings(s string) int {
2
+ ans := 0
3
+ n := len(s)
4
+
5
+ for i := 0; i < n; i++ {
6
+ for j := i+1; j <= n; j++ {
7
+ if (isPalindrom(s[i:j])) {
8
+ ans++
9
+ }
10
11
12
+ return ans
13
+}
14
15
+func isPalindrom(s string) bool {
16
+ var rev []byte
17
18
+ for i := n-1; i >= 0; i-- {
19
+ rev = append(rev, s[i])
20
21
+ return string(rev) == s
22
23
24
0 commit comments