【攻克力扣200题--33】127. 单词接龙

BFS

var ladderLength = function(beginWord, endWord, wordList) {
    let dict=new Set(wordList);
    if(!dict.has(endWord)) return 0;
    queue=[];
    queue.push(beginWord);
    let len=beginWord.length;
    var depth=0;
    while(queue.length>0){
        depth++;
        var size=queue.length;
        while(size-->0){
            var head=queue.shift();
            for(var i=0;i

 

你可能感兴趣的:(力扣攻克200题)