Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Solution:
  2. def dfs(self, s,res,index,cur_string):
  3. if cur_string==cur_string[::-1]:
  4. res.add(cur_string)
  5. for i in range(index,len(s)):
  6. self.dfs(s, res,i+1,cur_string+s[i])
  7. def countPalindromicSubsequences(self, S):
  8. BIG_NUM = 10**9+7
  9. res = set()
  10. s = S
  11. self.dfs(s,res,0,"")
  12. return (len(list(res))-1)%BIG_NUM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement