public static List<Integer> search(String text, String pattern){
        //only searches for upper case letters
        text = text.toUpperCase();
        pattern = pattern.toUpperCase();

        List<Integer> response = new ArrayList<>();
        HashSet<Character> dedup = new HashSet<>();
        for( int i = 0; i< pattern.length(); i++){
            if(!dedup.contains(pattern.charAt(i))){
                dedup.add(pattern.charAt(i));
            }
        }

        int[][] dfa = buildDFA(pattern, dedup);
        int i=0;
        //this loop is to make sure we keep finding more than one match
       // while(i<text.length()){
            int j=0;
            for( ; i<text.length() && j < pattern.length() ; i++){
                //keep looking for the next step.. make sure the chartacter in text is a part of pattern
                if(dedup.contains(text.charAt(i))){
                    j = dfa[text.charAt(i) - 'A'][j];
                }

            }
            //if j has reached the pattern length or last state .. means there is a match
            if(j == pattern.length()){
                //i-pattern.length() will give the start index from where the match begun
                response.add(i-pattern.length());
            }
       // }

        return response;

    }