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 1743351 commit ca4fdb7Copy full SHA for ca4fdb7
palindromic-substrings/sejineer.py
@@ -0,0 +1,19 @@
1
+"""
2
+시간 복잡도: O(N^2)
3
+공간 복잡도: O(1)
4
5
+class Solution:
6
+ def countSubstrings(self, s: str) -> int:
7
+ result = 0
8
+ def count_palindrome(left: int, right: int):
9
+ count = 0
10
+ while left >= 0 and right < len(s) and s[left] == s[right]:
11
+ count += 1
12
+ left -= 1
13
+ right += 1
14
+ return count
15
+
16
+ for i in range(len(s)):
17
+ result += count_palindrome(i, i)
18
+ result += count_palindrome(i, i + 1)
19
+ return result
0 commit comments