OJ-Problems-Source/LeetCode/187.py

12 lines
344 B
Python
Raw Normal View History

2023-11-05 20:00:25 +08:00
class Solution:
def findRepeatedDnaSequences(self, s: str) -> List[str]:
seen = set()
results = set()
for i in range(len(s) - 9):
pattern = s[i:i+10]
if pattern not in seen:
seen.add(pattern)
else:
results.add(pattern)
return list(results)