public int ladderLength2(String start, String end, Set<String> dict) {
        queue = new LinkedList<String>();
        queue.add(start);
        dict.add(end);
        int step = 1;
        while(!queue.isEmpty()){
            int count = queue.size();
            for(int i = 0; i < count; i++){
                String s = queue.poll();
                Set<String> tmpRemove = new HashSet<String>();
                for(String word : dict){
                    if(canTransform(s, word)){
                        if(word.equals(end)){
                            return step + 1;
                        }else{
                            queue.add(word);
                            tmpRemove.add(word);
                        }
                    }
                }
                dict.remove(tmpRemove);
            }
            step++;
        }
        return 0;
    }