← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

Intermediate
Apr 2026

Summary

Google SWE coding round with a graph/union-find propagation problem. The secret-spreading setup sounds simple but the multi-hop same-timestamp rule is what gets you.

Questions Asked (1)

Q1

Given n people where person 0 and one other person initially know a secret, and a list of timed meetings, determine which people know the secret after all meetings have occurred. The key rule: within the same timestamp, the secret can spread across multiple meetings in a chain.

Algorithms & Data Structures
Author's notes

The part that tripped me up was the same-timestamp multi-hop behavior.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Sort the meetings by timestamp, then process each timestamp group together: for each group, first collect all people who know the secret before any meetings at that time, then propagate the secret through all meetings in that group simultaneously. This ensures that within the same timestamp, the secret can spread across multiple meetings in a chain. Finally, return the set of people who know the secret.

Pro tip: Emphasize that processing each timestamp as a batch is crucial to handle chained propagation correctly; a common mistake is to process meetings sequentially, which fails when meetings at the same time are interdependent.

1. Understand the problem and constraints

Clarify that meetings are given as (time, person1, person2) and that within the same timestamp, the secret can spread through a chain of meetings. Confirm that person 0 and one other person initially know the secret.

2. Sort meetings by timestamp

Sort the list of meetings in ascending order of time. This groups meetings that occur at the same timestamp together.

3. Process each timestamp group

For each group of meetings with the same timestamp, first determine which people know the secret before any meetings at that time. Then, simulate the spread: for each meeting, if either person knows the secret, the other learns it. Because meetings are simultaneous, repeat this propagation until no new person learns the secret within the group (or use a union-find approach).

4. Update the set of knowers

After processing all meetings in the group, update the global set of people who know the secret to include those who learned it during this timestamp.

5. Return the final set

After all timestamp groups are processed, return the set of people who know the secret.

Key Points to Mention

  • Sorting meetings by time to handle chronological order
  • Grouping meetings by timestamp to process simultaneously
  • Using a set to track who knows the secret
  • Propagating the secret within a timestamp group until no new knowers (or using union-find for efficiency)
  • Time complexity: O(M log M) due to sorting, where M is number of meetings
  • Space complexity: O(N) for the set of knowers

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.