Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //高频班version
- public class Solution {
- /**
- * @param s: a string represent DNA sequences
- * @return: all the 10-letter-long sequences
- */
- public List<String> findRepeatedDna(String s) {
- // write your code here
- Set one = new HashSet();
- Set two = new HashSet();
- for (int i = 0; i < s.length() - 9; i++) {
- String tmp = s.substring(i, i + 10);
- if (!one.add(tmp)) {
- two.add(tmp);
- }
- }
- return new ArrayList(two);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment