public static boolean containsWordsFromDict(String s, String[] dict) {

        boolean[] contains = new boolean[s.length()+1];
        contains[0] = true;
        for( int i = 0; i< s.length(); i++) {

            if(!contains[i]) {
                continue;
            }

            for(String word : dict) {
                if(word.equals(s)) {
                    continue;
                }
                int end = i + word.length();

                if(end > s.length()) {
                    continue;
                }

                if(s.substring(i, end).equals(word)){
                    contains[end] = true;
                }

            }

        }

        return contains[s.length()];

    }