class Solution {
public List<String> findRepeatedDnaSequences(String s) {
Set<String> set=new HashSet<String>();
Set<String> res=new HashSet<String>();
for(int i=0;i+10<=s.length();i++)
{
String str=s.substring(i,i+10);
if(set.contains(str))
res.add(str);
else
set.add(str);
}
return new ArrayList<String>(res);
}
}
转载于:https://www.cnblogs.com/asuran/p/7734050.html