public int ladderLength(String start, String end, HashSet<String> dict) {
    	
    	dict.add(end);
    	
    	Queue<String> que = new LinkedList<String>(); 
    	que.offer(start);
    	que.offer(null);
    	int steps = 1;
    	while (que.size() > 0)
    	{
    		String str = que.poll();
    		
    		if (str == null)
    		{
    			steps++;
    			if (!que.isEmpty())
    				que.offer(null);
    		}
    		else
    		{
    			if (str.equals(end))
    				return steps;

        		for (int i = 0; i < str.length(); i++)
        			for (char c = 'a'; c <= 'z'; c++ )
        			{
        				if ( c == str.charAt(i))
        					continue;

            			char[] arr = str.toCharArray();
        				arr[i] = c;
        				String newstr = String.valueOf(arr);
        				if (dict.contains(newstr))
        				{
        					que.offer(newstr);
        					dict.remove(newstr);
        				}
        			}
    		}
    	}
    	
    	return 0;
    }