FastPrepFind All People With the Secret
Problems/Find All People With the Secret

Find All People With the Secret

Google logoGoogle● HardINTERNNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This was a PhD intern interview. The firsthand Google internship report names the secret-sharing problem with meetings at the same time. It highlights the rule for grouping equal timestamps. We supplied limits that work anywhere, and the final list of people must be in ascending order.

There are n people numbered from 0 to n - 1. Initially, person 0 shares a secret with firstPerson at time 0.

Each meeting is [x, y, time]. If either participant knows the secret at that time, both know it after the meeting. All meetings with the same timestamp happen simultaneously: knowledge may travel through an entire connected component formed by meetings at that timestamp, but it must not leak to a component that had no informed member when that timestamp began.

Return every person who knows the secret after all meetings, in ascending order.

Function

findAllPeople(n: int, meetings: int[][], firstPerson: int) → List<Integer>

Examples

Example 1

n = 6meetings = [[1,2,5],[2,3,8],[1,5,10]]firstPerson = 1return = [0,1,2,3,5]

People 0 and 1 start informed. Person 2 learns at time 5, person 3 at time 8, and person 5 at time 10.

Example 2

n = 6meetings = [[1,2,5],[2,3,5],[4,5,5]]firstPerson = 1return = [0,1,2,3]

At time 5, the informed person 1 spreads the secret through the simultaneous chain 1-2-3. The separate component 4-5 remains uninformed.

Constraints

  • 2 <= n <= 100000
  • 1 <= meetings.length <= 100000
  • Every meeting is [x, y, time] with 0 <= x, y < n, x != y, and 1 <= time <= 1000000000.
  • 1 <= firstPerson < n.
  • Duplicate meetings are allowed.

More Google Phone Screen questions

  • 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
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
  • Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
  • Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Find All People With SecretIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Find All People with the SecretAmazon · PHONE SCREEN
  • Contact Tracing Through Timed MeetingsHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Record Linkage Part 3 - Full Connected ComponentStripe · PHONE SCREENStripe interview questions
  • Evaluate DivisionApple · PHONE SCREENApple interview questions
  • Count Friend CirclesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Path Existence in an Undirected GraphByteDance · PHONE SCREENByteDance interview questions
  • Number of ProvincesSambaNova Systems · PHONE SCREENSambaNova Systems interview questions
  • Terminal Nodes for Each SourceIndeed · PHONE SCREENIndeed interview questions
  • Delivery Management SystemAkuna Capital · OAAkuna Capital interview questions

Interview reports that mention this question

  • Google SWE and PhD Intern Coding: 14 Experiences (Part 3 of 3)

Google interview experiences

  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
  • Google AI Coding Interview and AI OA: 2 Experiences
  • Google SWE Intern Interview Results Timeline: 13 Experiences
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public List<Integer> findAllPeople(int n, int[][] meetings, int firstPerson) {
        // Write your code here.
    }
}
Checking account…