Create 187.py

master
Kirigaya Kazuto 2023-11-05 20:00:25 +08:00 committed by GitHub
parent 56532f8280
commit ba0e3702f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

11
LeetCode/187.py Normal file
View File

@ -0,0 +1,11 @@
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)