Skip to content

Commit 85e4c0b

Browse files
committed
Runtime 233 ms (Top 71.99%) | Memory 21.0 MB (Top 5.67%)
1 parent 8bd94e4 commit 85e4c0b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution(object):
2+
def countPalindromicSubsequence(self, s):
3+
d=defaultdict(list)
4+
for i,c in enumerate(s):
5+
d[c].append(i)
6+
ans=0
7+
for el in d:
8+
if len(d[el])<2:
9+
continue
10+
a=d[el][0]
11+
b=d[el][-1]
12+
ans+=len(set(s[a+1:b]))
13+
return(ans)
14+

0 commit comments

Comments
 (0)