public int ladderLength(String start, String end, HashSet<String> dict) {

	HashSet<String> visited = new HashSet<String>();
	visited.add(start);

	HashSet<String> currentLayer = new HashSet<String>();
	currentLayer.add(start);

	HashSet<String> nextLayer = getNextLayer(currentLayer, dict, end,
		visited);
	int count = 2;

	while (!nextLayer.contains(end)) {
	    currentLayer = nextLayer;
	    nextLayer = getNextLayer(currentLayer, dict, end, visited);

	    if (nextLayer.isEmpty()) {
		return 0;
	    }

	    count++;
	}
	return count;
    }