def ladderLength(self, start, end, dict):
        path_len = 0
        lower_cases = [chr(i+ord('a')) for i in xrange(26)]

        queue = [start]
        dict.remove(start)
        while True:
            path_len += 1
            length_0 = len(queue)
            for i in xrange(length_0):  #O(V)
                current = queue[i]
                if current==end:  # reached
                    return path_len

                current = queue[i]
                for pos in xrange(len(current)):
                    lst = list(current)
                    for char in lower_cases:
                        lst[pos] = char
                        temp = "".join(lst)
                        if temp in dict:
                            queue.append(temp)
                            dict.remove(temp)

            queue = queue[length_0:]
            if not queue:
                return 0
        return path_len
bfs
dataset/ETHPy150Open algorhythms/LeetCode/127 Word Ladder.py/Solution.ladderLength