(queue, wordSet, seen, word, depth)
| 37 | }; |
| 38 | |
| 39 | const transform = (queue, wordSet, seen, word, depth) => { |
| 40 | for (const index in word) { |
| 41 | for (const char of 'abcdefghijklmnopqrstuvwxyz') { |
| 42 | const neighbor = getNeighbor(word, index, char); |
| 43 | |
| 44 | const hasSeen = !wordSet.has(neighbor) || seen.has(neighbor); |
| 45 | if (hasSeen) continue; |
| 46 | |
| 47 | queue.enqueue([neighbor, depth + 1]); |
| 48 | seen.add(neighbor); |
| 49 | } |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | const getNeighbor = (word, index, char) => { |
| 54 | const neighbor = word.split(''); |
no test coverage detected