public int ladderLength(String start, String end, Set<String> dict) {
		if (start.equals(end) || dict.size() == 0) {
			return 0;
		}
		Set<String> visited = new HashSet<String>();
		Queue<String> queue = new LinkedList<String>();
		queue.add(start);
		visited.add(start);
		int curLevelNum = 1;
		int nextLevelNum = 0;
		int level = 1;

		while (!queue.isEmpty()) {
			String cur = queue.poll();
			curLevelNum--;

			for (int i = 0; i < cur.length(); i++) {
				char[] curStr = cur.toCharArray();
				for (char j = 'a'; j <= 'z'; j++) {
					curStr[i] = j;
					String temp = String.valueOf(curStr);
					if (end.equals(temp)) {
						level++;
						return level;
					}
					if (dict.contains(temp) && !visited.contains(temp)) {
						visited.add(temp);
						queue.add(temp);
						nextLevelNum++;
					}
				}
			}
			if (curLevelNum == 0) {
				curLevelNum = nextLevelNum;
				nextLevelNum = 0;
				level++;
			}
		}
		return 0;
	}