FastPrepDetermine Whether Two Chickens Are Blood Relatives
Problems/Determine Whether Two Chickens Are Blood Relatives

Determine Whether Two Chickens Are Blood Relatives

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand Google new-grad report asks whether two chickens are related from parent-child links. The author clarifies that undirected union-find is wrong because a chicken's two parents can be connected through their child without being blood relatives, and confirms intersecting parent chains/ancestor sets.

A chicken family is represented by direct parent lists. parents[i] contains every direct parent of chicken i. Parent edges form a directed acyclic graph.

Two chickens are blood relatives when their ancestor sets intersect. A chicken is included in its own ancestor set, so an ancestor and descendant are relatives. Merely sharing a child does not make two co-parents blood relatives.

Return whether first and second are blood relatives.

Function

areBloodRelatives(parents: int[][], first: int, second: int) → boolean

Examples

Example 1

parents = [[],[],[0,1],[0,1]]first = 2second = 3return = true

The two chickens share parents 0 and 1.

Example 2

parents = [[],[],[0,1]]first = 0second = 1return = false

The two co-parents share a child but no ancestor.

Example 3

parents = [[],[0],[1]]first = 0second = 2return = true

Chicken 0 is an ancestor of chicken 2.

Constraints

  • 1 <= parents.length <= 200000.
  • Every listed parent is a valid node index.
  • The total number of parent edges is at most 300000.
  • The parent graph is acyclic.
  • first and second are valid indices.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Resolve Variable Equations with Dependency ErrorsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Nested Substitutions with Cycle DetectionKikoff · PHONE SCREENKikoff interview questions
  • Validate and Resolve Evaluation ChainsPlaid · PHONE SCREEN · ONSITE INTERVIEWPlaid interview questions
  • Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
  • Root of the Largest TreeGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Find the Unique User with Access to Every CameraVerkada · PHONE SCREENVerkada interview questions
  • Unique Transitive Dependent CountsRobinhood · PHONE SCREENRobinhood interview questions
  • Best Currency Round Trip Over Two DaysRippling · PHONE SCREENRippling interview questions
  • Currency Conversion Through Exchange PathsStripe · PHONE SCREENStripe interview questions

Interview reports that mention this question

  • Google New Grad R1 Chicken Blood Relatives: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean areBloodRelatives(int[][] parents, int first, int second) {
        // Write your code here.
    }
}
Checking account…