这题考查的东西,确实是盲区了,一直没掌握。首先可以用暴力,当然了,TLE是必然的。不过可以看第二种,是讨论区的大神的思路。
第一种:
class Solution:
def wonderfulSubstrings(self, word: str) -> int:
res = len(word)
for leng in range(1, len(word)):
for i in range(0, len(word) - leng):
subsequence = word[i:i+leng+1