sweet1cris

Untitled

Feb 10th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1.  
  2. //高频班version
  3. public class Solution {
  4.     /**
  5.      * @param s: a string represent DNA sequences
  6.      * @return: all the 10-letter-long sequences
  7.      */
  8.     public List<String> findRepeatedDna(String s) {
  9.         // write your code here
  10.         Set one = new HashSet();
  11.         Set two = new HashSet();
  12.         for (int i = 0; i < s.length() - 9; i++) {
  13.             String tmp = s.substring(i, i + 10);
  14.             if (!one.add(tmp)) {
  15.                 two.add(tmp);
  16.             }
  17.         }
  18.         return new ArrayList(two);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment