Tap here to switch tabs
Problem
Submissions

Problem: Minimum Genetic Mutation

Minimum Genetic Mutation asks you to transform one gene string into another with single-character changes, using only intermediate strings from the valid bank, and return the fewest mutations or -1.

Statement

You are given two gene strings startGene and endGene, along with a list bank of valid gene strings. A single mutation changes exactly one character in the current gene to a different character.

Return the minimum number of mutations needed to transform startGene into endGene, where every intermediate gene string produced during the process must appear in bank. If it is impossible to reach endGene under these rules, return −1-1.

Implement int minMutation(str startGene, str endGene, List[str] bank).

Note: Each mutation must change exactly one position, and every intermediate gene must be contained in bank.

Constraints:

  • 0≤0 \leq bank.length ≤10\leq 10

  • startGene.length ==== endGene.length ==== bank[i].length ==8== 8

  • startGene, endGene, and bank[i] consist only of the characters ['A', 'C', 'G', 'T']

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Genetic Mutation

Minimum Genetic Mutation asks you to transform one gene string into another with single-character changes, using only intermediate strings from the valid bank, and return the fewest mutations or -1.

Statement

You are given two gene strings startGene and endGene, along with a list bank of valid gene strings. A single mutation changes exactly one character in the current gene to a different character.

Return the minimum number of mutations needed to transform startGene into endGene, where every intermediate gene string produced during the process must appear in bank. If it is impossible to reach endGene under these rules, return −1-1.

Implement int minMutation(str startGene, str endGene, List[str] bank).

Note: Each mutation must change exactly one position, and every intermediate gene must be contained in bank.

Constraints:

  • 0≤0 \leq bank.length ≤10\leq 10

  • startGene.length ==== endGene.length ==== bank[i].length ==8== 8

  • startGene, endGene, and bank[i] consist only of the characters ['A', 'C', 'G', 'T']