Skip to content

Commit 824d1a0

Browse files
committed
feat: Solve palindromic-substrings problem
1 parent da32e17 commit 824d1a0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

palindromic-substrings/hu6r1s.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class Solution:
22
"""
3-
3+
브루트포스로 모두 탐색하면서 집어넣는 방법
4+
O(n^2)
45
"""
5-
def countSubstrings(self, s: str) -> int:
6-
cnt = []
7-
for i in range(len(s)):
8-
for j in range(i, len(s)):
9-
sub = s[i:j+1]
10-
if sub and sub == sub[::-1]:
11-
cnt.append(sub)
12-
return len(cnt)
6+
def countSubstrings(self, s: str) -> int:
7+
cnt = []
8+
for i in range(len(s)):
9+
for j in range(i, len(s)):
10+
sub = s[i:j+1]
11+
if sub and sub == sub[::-1]:
12+
cnt.append(sub)
13+
return len(cnt)

0 commit comments

Comments
 (0)