Problem
A gene is a string of 8 characters, each one of A, C, G or T. A mutation changes exactly one character of a gene. You are given a start gene, an end gene and a bank of allowed genes. Every gene you mutate into must be in the bank (start itself does not have to be). Return the fewest mutations that turn start into end, 0 if they are already equal, or -1 if it cannot be done.
Example 1
- Input
- start = "TTGGCCAA", end = "TTGGCCAC", bank = ["TTGGCCAC"]
- Output
- 1
Example 2
- Input
- start = "GGGGGGGG", end = "TTGGGGGG", bank = ["TGGGGGGG", "TTGGGGGG", "GTGGGGGG"]
- Output
- 2
Example 3
- Input
- start = "AACCTTGG", end = "AACCTTGA", bank = []
- Output
- -1
Constraints
0 <= bank.length <= 10start, end and every bank[i] have length 8.Every gene contains only the characters A, C, G and T.