public static void wordBreak(String s, Set<String> dict) {
        boolean[] isWord = new boolean[s.length()+1];
        int[] revPointer = new int[s.length()+1];

        isWord[0] = true;
        // add the first index as the front pointer for 0th index
        //frontPointer.put(0, new ArrayList<Integer>());
        //frontPointer.get(0).add(1);

        for( int i = 0; i< s.length(); i++) {

            // start from the matching word
            if(!isWord[i]) {
                continue;
            }

            for( String word : dict) {
                int end = i + word.length();

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

                if(isWord[end]) {
                    continue;
                }

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

                }

            }

        }


    }