Problem · Combinatorics
ABO Parent Genotype Combinations
Learn this problemProblem statement
Use the standard simplified ABO inheritance model:
- Phenotype
Ahas genotypeAAorAO. - Phenotype
Bhas genotypeBBorBO. - Phenotype
ABhas genotypeAB. - Phenotype
Ohas genotypeOO.
A child receives one allele from each parent. Given the phenotypes of parent one, parent two, and the child, return every ordered parent-genotype pair that can produce the child's phenotype.
Encode a pair as parentOneGenotype|parentTwoGenotype. Use the canonical genotype spellings above, return no duplicates, and sort the result lexicographically.
Function
possibleParentGenotypes(parentOnePhenotype: String, parentTwoPhenotype: String, childPhenotype: String) → String[]Examples
Example 1
parentOnePhenotype = "A"parentTwoPhenotype = "B"childPhenotype = "O"return = ["AO|BO"]An O child must receive an O allele from each parent, so both parents must carry O.
Example 2
parentOnePhenotype = "AB"parentTwoPhenotype = "O"childPhenotype = "A"return = ["AB|OO"]The first parent can contribute A and the second contributes O, producing genotype AO and phenotype A.
Constraints
- Each phenotype is exactly one of
A,B,AB, orO. - Parent order is significant in the returned encoding.
- The simplified model considers only the A, B, and O alleles and does not model other blood-group factors.