LIMITED TIME 🎁: Register now to get 60 minutes of AI Mock Interviewing for FREE!

Join
    Back to Blog

    Interview Prep

    Google Software Engineer Interview 2026: A Real Onsite Coding Question and What It Tests

    Chengxi Jing · Marketing Specialist ·

    Google Software Engineer interview 2026

    Quick Answer

    In one recent Intermediate Google Software Engineer onsite Coding / Algorithms report shared with Screna, the candidate was asked to determine whether a parent array describes a valid rooted tree.

    The candidate jumped into cycle detection, then had to backtrack when the interviewer asked what happens if there are two roots. A stronger approach was to define the validity contract first: exactly one root, no self-loop, and full reachability from that root. The practical lesson is simple: state the conditions, surface edge cases, then implement and test.

    URL:https://www.screna.ai/experience/71f3a501-fa08-41fe-be27-e70c136ec9c6

    Interview Snapshot

    CompanyGoogle
    RoleSoftware Engineer
    LevelIntermediate
    Reported RoundOnsite - Coding / Algorithms
    Question ThemeParent array, rooted-tree validation, traversal, edge cases
    MentorSarah Millstone

    Where This Case Fits in the Google SWE Interview Process

    Candidate experiences may include a technical screen, onsite or virtual onsite, and post-interview review or team-matching stages. The sequence varies by team, location, level, and hiring cycle. Coding rounds can require collaborative reasoning as well as implementation; system design should not be assumed for every early-career or intermediate loop.

    Scope note: This article focuses on one reported onsite coding round and does not claim a fixed number of Google interviews.

    The Real Coding Question: Is This Parent Array a Valid Tree?

    The interviewer asked the candidate to validate an integer array in which parent[i] gives the parent of node i and -1 marks the root.

    Candidate reflection: "I jumped straight to cycle detection and forgot to check for multiple roots first."

    When the interviewer introduced the two-root case, the candidate had to reorganize the solution. A cleaner structure is:

    1. Verify there is exactly one -1 entry.
    2. Reject explicit self-loops such as parent[i] == i.
    3. Build parent-to-children relationships and traverse from the root.
    4. Confirm that every node is reached.

    The goal is to prove that the input satisfies the definition of a rooted tree and make that reasoning visible before coding.

    Mentor Analysis: Write the Failure Modes Before the Code

    Screna AI mentor Sarah Millstone identified the issue as sequencing, not lack of algorithm knowledge. Her advice was to resist the automatic cycle-detection reflex and define the contract first.

    "Before writing a single line of code, I'd list the ways the input can be malformed as plain English on the board."

    For this problem, that includes zero roots, multiple roots, a self-loop, a cycle, or a disconnected subtree. Instead of discovering edge cases reactively, the candidate turns each failure mode into a deliberate check. Millstone also recommends scanning for parent[i] == i explicitly so the self-loop is visibly handled.

    What This Case May Reveal About Evaluation

    This is one candidate-reported Google onsite question, not an official Google question bank. Still, it may highlight four useful evaluation signals:

    • Requirements-first reasoning: define what "valid" means before choosing an algorithm.
    • Edge-case coverage: surface multiple roots, self-loops, cycles, and disconnected nodes early.
    • Communication under pressure: recover from a missed case without losing the structure.
    • Testing discipline: test malformed inputs, not only the happy path.

    A correct final solution can still look weaker if the reasoning arrives through avoidable backtracking.

    A Focused Google SWE Preparation Plan

    Practice graph and tree problems in two passes. First, spend 30-60 seconds writing the input contract, failure modes, and expected complexity. Then choose DFS, BFS, cycle detection, or another technique.

    For this pattern, rehearse a single-node tree, two -1 entries, a self-loop, a disconnected cycle, and a valid multi-level tree. Explain why each passes or fails.

    Frequently Asked Questions

    Does Google always ask tree-validation questions?

    No. This is one recent candidate-reported question, not a prediction.

    What was the candidate's biggest mistake?

    Starting with cycle detection before defining the full validity conditions, especially exactly one root.

    Does every Google SWE interview include system design?

    Not necessarily. Relevance varies by role and seniority; prepare against the recruiter-confirmed loop.

    What happens after a Google onsite?

    Candidate-reported experiences may include hiring review and team matching, but the sequence and timing can vary.