public boolean wordBreak_BFS(String s, Set<String> wordDict) {
        Queue<Integer> bfs = new LinkedList<Integer>();
        HashSet<String> wordSet = new HashSet<String>();
        HashSet<Integer> visited = new HashSet<Integer>();
        for (String str : wordDict)
            wordSet.add(str);
        bfs.offer(0);
        while (!bfs.isEmpty()) {
            int start = bfs.poll();
            if (!visited.contains(start)) {
                visited.add(start);
                for (int i = start; i < s.length(); ++i) {
                    String str = s.substring(start, i + 1);
                    if (wordSet.contains(str)) {
                        bfs.add(i + 1);
                        if (i + 1 == s.length())
                            return true;
                    }
                }
            }
        }
        return false;
    }