public int ladderLength(String start, String end, Set<String> dict) {
            if (start == null || end == null || start.length() != end.length()) 
                return 0;
            
            Set<String> last;
            Set<String> next = new LinkedHashSet<>();
            next.add(start);
            dict.remove(start);
            dict.add(end);
            
            int depth = 0;
            while (!next.isEmpty()) {
                depth++;
                
                last = next;
                next = new LinkedHashSet<>();
                for (String s : last) {
                    if (s.equals(end)) return depth;
                    
                    next.addAll(this.getAdjacent(dict, s));
                }
            }
            
            return 0;
        }