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 f770374 commit 052d112Copy full SHA for 052d112
palindromic-substrings/Raft.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def countSubstrings(self, s: str) -> int:
3
+ count = 0
4
+ for i in range(len(s)):
5
+ count += self.countPalindrome(s, i, i)
6
+ count += self.countPalindrome(s, i, i + 1)
7
+ return count
8
+
9
+ def countPalindrome(self, s, l, r):
10
11
+ while r < len(s) and l >= 0 and s[l] == s[r]:
12
+ count += 1
13
+ l -= 1
14
+ r += 1
15
16
+# T: O(n^2)
17
+# S: O(n^2)
18
0 commit comments