public List<String> findRepeatedDnaSequences(String s) {

        if (s.length() < 10) {
            return Collections.emptyList();
        }

        Set<Integer> set = new HashSet<>();
        int val = 0;
        for (int i = 0; i < 10; i++) {
            val = add(val, s.charAt(i));
        }
        set.add(val);
        List<String> result = new ArrayList<>();
        createString(val);

        Set<Integer> repeatSet = new HashSet<>();

        for (int i = 10; i < s.length(); i++) {
            val = add(val, s.charAt(i));
            if (set.contains(val) && !repeatSet.contains(val)) {
                result.add(createString(val));
                repeatSet.add(val);
            } else {
                set.add(val);
            }
        }

        return result;
    }
Date 03/08/2016
@author Tushar Roy

Find repeated sequence of length 10 in string consisting of A,C,G,T

Time complexity is O(n)
Space complexity is O(n)

https://leetcode.com/problems/repeated-dna-sequences/
src/com/interview/bits/RepeatedDnaSequence.java