package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/repeated-dna-sequences/
 */
public class Problem187 {
    public List<String> findRepeatedDnaSequences(String s) {
        List<String> result = new ArrayList<>();
        // TODO
        return result;
    }

    public static void main(String[] args) {
        Problem187 prob = new Problem187();
//                                                             CCCCCAAAAA CCCCCAAAAA
//                                                       AAAAACCCCC AAAAACCCCC
        System.out.println(prob.findRepeatedDnaSequences("AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"));
    }
}

@@ -57,19 +57,67 @@
 va.util.
-Lis
+HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0A/**%0A
@@ -272,19 +272,18 @@
         
-Lis
+Se
 t%3CString
@@ -288,21 +288,18 @@
 ng%3E 
-resul
+se
 t = new 
 Arra
@@ -294,24 +294,22 @@
 t = new 
-ArrayLis
+HashSe
 t%3C%3E();%0A 
@@ -319,137 +319,132 @@
     
-// TODO%0A        return result
+Set%3CString%3E result = new HashSet%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem187 prob = new Problem187();%0A//
+for (int i = 0; i %3C s.length(); i++) %7B%0A            if (i + 10 %3E s.length()) %7B%0A
     
@@ -447,32 +447,39 @@
                 
+break;%0A
                 
@@ -466,32 +466,34 @@
 ak;%0A            
+%7D%0A
                 
@@ -492,59 +492,115 @@
     
-                     CCCCCAAAAA CCCCCAAAAA%0A//      
+String str = s.substring(i, i + 10);%0A            if (set.contains(str)) %7B%0A                result.add(str);%0A
     
@@ -599,34 +599,41 @@
 r);%0A            
-  
+%7D else %7B%0A
                 
@@ -636,141 +636,83 @@
     
-                   AAAAACCCCC AAAAACCCCC%0A        System.out.println(prob.findRepeatedDnaSequences(%22AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT%22)
+set.add(str);%0A            %7D%0A        %7D%0A        return new ArrayList%3C%3E(result
 );%0A 

Solve problem 187