<awangdev>Word Ladder_2.java
public int ladderLength(String start, String end, Set<String> dict) {
    	if (start == null || end == null || dict == null || start.length() != end.length()) {
    		return 0;
    	}
    	Queue<String> q = new LinkedList<String>();
    	HashSet<String> set = new HashSet<String>();
    	int level = 1;
    	int len = Integer.MAX_VALUE;
    	q.offer(start);
    	set.add(start);
    	while(!q.isEmpty()) {
    		int size = q.size();
    		level++;
    		for (int k = 0; k < size; k++) {
	    		String str = q.poll();
	    		for (int i = 0; i < str.length(); i++) {
	    			for (int j = 0; j < 26; j++) {
	    				String newStr;
	    				if (i == 0 && str.length() == 1) {
	    				    newStr = "" + (char)('a' + j);
	    				}
	    				else if (i == str.length() - 1) {
	    					newStr = str.substring(0, i) + (char)('a' + j);
	    				} else {
	 						newStr = str.substring(0, i) + (char)('a' + j) + str.substring(i + 1);
	    				}
	    				if (!set.contains(newStr) && dict.contains(newStr)) {
	    					if (newStr.equals(end)) {
	    						len = Math.min(len, level);
	    					} else {
	    						set.add(newStr);
	    						q.offer(newStr);
	    					}
	    				}
	    			}
	    		}
	    	}
    	}
    	return len;
    }
public int sample_funcname ( String var_1 , String var_2 , Set < String > var_4 ) {
  if ( var_1 == null || var_2 == null || var_4 == null || var_1 . length ( ) != var_2 . length ( ) ) {
    return 0 ;
  }
  Queue < String > var_10 = new LinkedList < String > ( ) ;
  HashSet < String > var_12 = new HashSet < String > ( ) ;
  int var_14 = 1 ;
  int var_17 = Integer . MAX_VALUE ;
  var_10 . offer ( var_1 ) ;
  var_12 . add ( var_1 ) ;
  while ( ! var_10 . isEmpty ( ) ) {
    int size = var_10 . size ( ) ;
    var_14 ++ ;
    for ( int var_22 = 0 ;
    var_22 < size ;
    var_22 ++ ) {
      String var_24 = var_10 . poll ( ) ;
      for ( int var_25 = 0 ;
      var_25 < var_24 . length ( ) ;
      var_25 ++ ) {
        for ( int var_26 = 0 ;
        var_26 < 26 ;
        var_26 ++ ) {
          String var_28 ;
          if ( var_25 == 0 && var_24 . length ( ) == 1 ) {
            var_28 = "" + ( char ) ( 'a' + var_26 ) ;
          }
          else if ( var_25 == var_24 . length ( ) - 1 ) {
            var_28 = var_24 . substring ( 0 , var_25 ) + ( char ) ( 'a' + var_26 ) ;
          }
          else {
            var_28 = var_24 . substring ( 0 , var_25 ) + ( char ) ( 'a' + var_26 ) + var_24 . substring ( var_25 + 1 ) ;
          }
          if ( ! var_12 . contains ( var_28 ) && var_4 . contains ( var_28 ) ) {
            if ( var_28 . equals ( var_2 ) ) {
              var_17 = Math . min ( var_17 , var_14 ) ;
            }
            else {
              var_12 . add ( var_28 ) ;
              var_10 . offer ( var_28 ) ;
            }
          }
        }
      }
    }
  }
  return var_17 ;
}
