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

Find All People with the Secret

Amazon logoAmazon● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time phone screen. The secret-sharing task is about 95% the same as the named interview problem. We added the input limits and an output in ascending order.

There are n people labeled from 0 to n - 1. At time 0, person 0 shares a secret with firstPerson.

Each row [x, y, time] in meetings describes a meeting between people x and y. If either knows the secret at that time, the other learns it. Sharing is instantaneous: the secret can travel through a chain of meetings at the same time, regardless of their input order.

People retain the secret after learning it, but a meeting connects its participants only at its own time. Return all people who know the secret after every meeting, sorted in ascending order.

Function

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

Examples

Example 1

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

At time 5, person 1 shares through person 2 to person 3, even though the second link is listed first. Neither participant at time 6 knows the secret.

Example 2

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

The meeting at time 1 shares no secret. Person 2 learns it at time 2, but that does not reactivate the past meeting with person 3.

Example 3

n = 4meetings = []firstPerson = 3return = [0,3]

Without meetings, only the two initial holders know the secret.

Constraints

  • For this exercise, assume 2 <= n <= 10^5 and 0 <= meetings.length <= 10^5.
  • Every meeting is [x,y,time], where 0 <= x,y < n, x != y, and 1 <= time <= 10^9.
  • 1 <= firstPerson < n.
  • Meetings may be unsorted, repeat the same participants, or share a timestamp.

More Amazon Phone Screen questions

  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Find All People With the SecretGoogle · PHONE SCREENGoogle interview questions
  • Contact Tracing Through Timed MeetingsHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Terminal Nodes for Each SourceIndeed · PHONE SCREENIndeed interview questions
  • Find All People With SecretIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Delivery Management SystemAkuna Capital · OAAkuna Capital interview questions
  • Distributed System RecoveryRippling · OARippling interview questions
  • Bus RoutesUiPath · PHONE SCREEN
  • Minimum Bus Routes to a DestinationPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Grid Robot Route with Charging PrioritiesUber · PHONE SCREEN · ONSITE INTERVIEWUber interview questions
  • Find Duplicate Files in a FilesystemHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public List<Integer> findAllPeople(int n, int[][] meetings, int firstPerson) {
        // Write your code here.
    }
}
Checking account…