FastPrepFind All People with the Secret

Find All People with the Secret

Amazon logoAmazon● HardFULLTIMEPHONE SCREEN

Problem statement

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.

The problem statement continues
Pro

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.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Amazon hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week