Problem · Array
Find All People With Secret
Learn this problemProblem statement
People are labeled from 0 to n - 1. Person 0 initially shares a secret with firstPerson at time 0. Each meeting [x, y, time] allows either participant to share the secret with the other at that time.
Secret sharing is instantaneous, so information may propagate through several meetings that occur at the same time. Return all people who know the secret after every meeting, sorted in ascending order.
Function
findAllPeople(n: int, meetings: int[][], firstPerson: int) → int[]Examples
Example 1
n = 6meetings = [[1,2,5],[2,3,8],[1,5,10]]firstPerson = 1return = [0,1,2,3,5]Example 2
n = 4meetings = [[1,2,2],[3,1,3],[0,3,3]]firstPerson = 3return = [0,1,3]