public ArrayList<String> findNextStrs(String word, Map<String, Boolean> visited, 
				Map<String, List<String>> parents, HashSet<String> dict, String end) {
		ArrayList<String> res = new ArrayList<String>();
		char[] str = word.toCharArray();
		for(int i = 0; i < str.length; i++) {
			char ch = str[i];
			for(char newCh = 'a'; newCh <= 'z'; newCh++) {
				if(newCh != ch) {
					str[i] = newCh;
					String temp = new String(str);
					// as the end word could be reached from several words
					if(temp.equals(end) || (dict.contains(temp) && !visited.get(temp))) {
						res.add(temp);
						if(parents.get(temp) == null) {
							ArrayList<String> list = new ArrayList<String>();
							list.add(word);
							parents.put(temp, list);
						} else {
							parents.get(temp).add(word);
						}
					}
				}
			}
			str[i] = ch;
		}
		return res;
	}