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 833fda5 commit 6139c9cCopy full SHA for 6139c9c
1 file changed
palindromic-substrings/hajunyoo.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def countSubstrings(self, s: str) -> int:
3
+ self.count = 0
4
+ n = len(s)
5
+
6
+ def two_pointer_expand(left, right):
7
+ while left >= 0 and right < n and s[left] == s[right]:
8
+ self.count += 1
9
+ left -= 1
10
+ right += 1
11
12
+ for i in range(0, n):
13
+ # 1, 3, 5 ...
14
+ two_pointer_expand(i, i)
15
+ # 2, 4, 6 ...
16
+ two_pointer_expand(i, i + 1)
17
18
+ return self.count
0 commit comments