ABO Parent Genotype Combinations
Updated
Problem statement
Use the usual simple ABO blood-type model. A person's blood type is the phenotype, and the pair of alleles behind it is the genotype:
- Phenotype
Ahas genotypeAAorAO. - Phenotype
Bhas genotypeBBorBO. - Phenotype
ABhas genotypeAB. - Phenotype
Ohas genotypeOO.
A child gets one allele from each parent. You are given the phenotype of parent one, the phenotype of parent two, and the phenotype of the child. Return every pair of parent genotypes that could give a child with that phenotype. The order inside a pair matters: parent one comes first.
Write each pair as parentOneGenotype|parentTwoGenotype. Spell each genotype exactly as in the list above. Do not repeat a pair, and sort the result lexicographically (plain dictionary order).
Function
possibleParentGenotypes(parentOnePhenotype: String, parentTwoPhenotype: String, childPhenotype: String) → String[]Examples
Example 1
parentOnePhenotype = "A"parentTwoPhenotype = "B"childPhenotype = "O"return = ["AO|BO"]An O child needs an O allele from each parent. So parent one, who has phenotype A, must be AO, and parent two, who has phenotype B, must be BO. The only pair is AO|BO.
Example 2
parentOnePhenotype = "AB"parentTwoPhenotype = "O"childPhenotype = "A"return = ["AB|OO"]Phenotypes AB and O each have only one genotype, so parent one is AB and parent two is OO. Parent one can pass A and parent two passes O, so the child can be AO, which is phenotype A. The answer is AB|OO.
Constraints
- Each phenotype is exactly one of
A,B,AB, orO. - Parent order matters in each returned pair.
- The model uses only the A, B, and O alleles. It ignores all other blood-group factors.
More Upstart Online Assessment questions
- Buffet Day GainsOA · Seen Sep 2026
- Case-Insensitive Anagram CheckOA · Seen Sep 2026
- Filter Duplicates While Preserving OrderOA · Seen Sep 2026
- Scale Ingredient QuantitiesOA · Seen Sep 2026
- Chunked Byte Stream ChecksumsOA · Seen Aug 2026
- Cluster Size on DiskOA · Seen Aug 2026
- Double Substitution DecryptionOA · Seen Aug 2026
- Add Drama to Text GroupsOA · Seen Jul 2026
- Lexicographic Word FrequenciesOA · Seen Jul 2026
- Minimum Absolute Pair DifferenceOA · Seen Jul 2026
Similar questions at other companies
- Cheating CodemakerJane Street · OA
- Best Poker Category with a JokerScale AI · PHONE SCREEN · ONSITE INTERVIEW
- Find All Zip Rummy MeldsZip · PHONE SCREEN · ONSITE INTERVIEW
- Deduplicated Query RegistrationDatadog · ONSITE INTERVIEW
- Fixed-Range Frequency CountWaymo · PHONE SCREEN
- Split Tender Part 2 - Expiration DatesStripe · OA
- Organization Reputation After Employee DeparturesHSBC · OA
- Bank Accounts with Balance HistoryMeta · OA
- Count Overlapping Square PairsRamp · OA
- Find Valid SET Card TriplesSnowflake · OA · PHONE SCREEN