Could anyone help me to check why my solution receives duplicate results?
<blockquote>
<p>All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: &quot;ACGAATTCCG&quot;. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.</p>
<p>Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.</p>
<p>For example,</p>
<p>Given <code>s = &quot;AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT&quot;</code>,</p>
<p>Return:
<code>[&quot;AAAAACCCCC&quot;, &quot;CCCCCAAAAA&quot;]</code>.</p>
</blockquote>
<p>My code:</p>
<pre><code>public class Solution {
public List&lt;String&gt; findRepeatedDnaSequences(String s) {
    List&lt;String&gt; res = new ArrayList&lt;String&gt;();
    
    if(s == null || s.length() == 0){
        return res;
    }
    
    for(int i = 0; i &lt; s.length() - 10; i++){
        // System.out.print(occurance(s,sub) + &quot;,&quot;);
        String sub = s.substring(i, i+10);//endIndex is exclusive
        System.out.print(occurance(s,sub) + &quot;,&quot;);
        if(occurance(s,sub) &gt; 1){
            res.add(sub);
        }
    }
    return res;
}

private int occurance(String s, String sub){
    int occurTimes = 0;
    for(int i = 0; i &lt; s.length() - sub.length(); i++){
        for(int j = 0; j &lt; sub.length(); j++){
            if(sub.charAt(j) != s.charAt(i+j)){
                break;
            }
            if(j == sub.length() - 1){
                occurTimes++; 
            }
        }
    }
    return occurTimes;
  }
}
</code></pre>