A gene string has 8 characters, each one of A, C, G or T. One mutation changes exactly one character. Every intermediate gene, and the end gene, must be in the bank. Given startGene, endGene and bank, return the minimum number of mutations needed to turn startGene into endGene, or -1 if it cannot be done.
A gene string has 8 characters, each one of A, C, G or T. One mutation changes exactly one character. Every intermediate gene, and the end gene, must be in the bank. Given startGene, endGene and bank, return the minimum number of mutations needed to turn startGene into endGene, or -1 if it cannot be done.
Breadth-first search from AACCGGTT. Each bank gene that differs from the current gene in exactly one letter is one mutation away. The first time AAACGGTA comes off the queue, its step count is the minimum.