标签:leetcode
https://oj.leetcode.com/problems/repeated-dna-sequences/
public List<String> findRepeatedDnaSequences(String s) { // Assumptions... List<String> toReturn = new ArrayList<>(); Set<String> seen = new HashSet<>(); for (int i = 0 ; i <= s.length() - 10 ; i ++) { String sub = s.substring(i, i + 10); if (seen.contains(sub)) { toReturn.add(sub); } else { seen.add(sub); } } return toReturn; }
[LeetCode]187 Repeated DNA Sequences
标签:leetcode
原文地址:http://7371901.blog.51cto.com/7361901/1615197