@@ -67,29 +67,29 @@ public List<List<String>> findLadders(String start, String end, List<String> dic
67
67
StringBuilder builder = new StringBuilder (word );
68
68
for (char ch = 'a' ; ch <= 'z' ; ch ++) {
69
69
builder .setCharAt (i , ch );
70
- String new_word = builder .toString ();
71
- if (ladder .containsKey (new_word )) {
70
+ String newWord = builder .toString ();
71
+ if (ladder .containsKey (newWord )) {
72
72
73
- if (step > ladder .get (new_word )) {//Check if it is the shortest path to one word.
73
+ if (step > ladder .get (newWord )) {//Check if it is the shortest path to one word.
74
74
continue ;
75
- } else if (step < ladder .get (new_word )) {
76
- queue .add (new_word );
77
- ladder .put (new_word , step );
75
+ } else if (step < ladder .get (newWord )) {
76
+ queue .add (newWord );
77
+ ladder .put (newWord , step );
78
78
} else ;// It is a KEY line. If one word already appeared in one ladder,
79
79
// Do not insert the same word inside the queue twice. Otherwise it gets TLE.
80
80
81
- if (map .containsKey (new_word )) {//Build adjacent Graph
82
- map .get (new_word ).add (word );
81
+ if (map .containsKey (newWord )) {//Build adjacent Graph
82
+ map .get (newWord ).add (word );
83
83
} else {
84
84
List <String > list = new LinkedList <String >();
85
85
list .add (word );
86
- map .put (new_word , list );
86
+ map .put (newWord , list );
87
87
//It is possible to write three lines in one:
88
88
//map.put(new_word,new LinkedList<String>(Arrays.asList(new String[]{word})));
89
89
//Which one is better?
90
90
}
91
91
92
- if (new_word .equals (end )) {
92
+ if (newWord .equals (end )) {
93
93
min = step ;
94
94
}
95
95
0 commit comments