public ArrayList<ArrayList<String>> findLadders(String start, String end, HashSet<String> dict) {
		    ArrayList<ArrayList<String>> allPaths = new ArrayList<ArrayList<String>>();
		    HashMap<String, String> parent = new HashMap<String, String>();
		   

		    parent.put(start, null);

		    ArrayList<String> frontier = new ArrayList<String>();//queue
		    frontier.add(start);
		    
		    
		    Object[] temp = new Object[dict.size()];        // convert HashSet to String[]
		    temp = dict.toArray();
		    String[] dic = new String[dict.size()];
		    for(int i=0;i<dict.size();i++){
		        dic[i] = temp[i].toString();
		    }
		    
		    ArrayList<String> allNext = new ArrayList<String>();
		    ArrayList<String> next = new ArrayList<String>();
		    ArrayList<String> path = new ArrayList<String>();
		   
		    while(!frontier.isEmpty()){
		    	allNext = new ArrayList<String>();
		        boolean found = false;// determine whether the shortest answers have been found.

		        for(String u: frontier){			//BFS
		            next = nextString(u, dic);    
		            for(String v: next){
		                if(!parent.containsKey(v)){
		                    parent.put(v, u);
		                    allNext.add(v);

		                    if(oneCharDiffered(v, end)){
		                        path = new ArrayList<String>();
		                        path.add(end);

		                        String current = v;
		                        while(parent.get(current) != null){
		                            path.add(current);
		                            current = parent.get(current);
		                        }
		                        path.add(current);
		                        allPaths.add(path);
		                        found = true;
		                    }

		                }   
		            }

		        }
		        frontier = allNext;
		        if(found == true) return allPaths; //if the shortest step answers have been found, return the paths.
		    }   
		    return null;
		}