Plague Survivor Prediction (Game Adaptation)
Updated
Problem statement
Game model. This exercise uses an explicit infection model.
For this exercise, animals have IDs 0..n-1. Each row [a,b] in contacts means animals a and b are in contact; infection can spread in either direction. The animals listed in infected are infected at round 0. During each round, all infected animals spread the infection to their uninfected neighbors at the same time. Newly infected animals start spreading in the next round. Infection never disappears.
An animal is a survivor in this model if it remains uninfected after exactly rounds rounds. Return the survivor IDs in ascending order. An animal infected at round 0 is never a survivor. Keep all inputs unchanged.
Function
plagueSurvivors(n: int, contacts: int[][], infected: int[], rounds: int) → int[]Examples
Example 1
n = 4contacts = [[0,1],[1,2],[2,3]]infected = [0]rounds = 1return = [2,3]After one round only animals 0 and 1 are infected.
Example 2
n = 4contacts = [[0,1],[1,2],[2,3]]infected = [0,3]rounds = 1return = []The two initial infections reach every animal after one round.
Example 3
n = 3contacts = [[0,1]]infected = []rounds = 100return = [0,1,2]With no initial infection, every animal remains uninfected.
Constraints
0 <= n <= 2000;0 <= contacts.length <= 10000.- Every contact joins two different valid IDs; undirected contacts are unique.
infectedcontains unique valid IDs and may be empty.0 <= rounds <= 1000000000.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
- Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025
Similar questions at other companies
- Delivery Management SystemAkuna Capital · OAAkuna Capital interview questions
- Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
- Tree Pythagorean TriplesIBM · OAIBM interview questions
- Shortest Atom Action PathOpenAI · OAOpenAI interview questions
- Distances to CyclesBelvedere Trading · OA
- Shortest Path from an Encoded GraphIntuit · OAIntuit interview questions
- Minimize Malware Spread by Removing a NodeVisa · OAVisa interview questions
- Longest Distance in a Frequency-Limited NetworkBloomberg LP · OABloomberg LP interview questions
- Minimum Cleaning Robot RunsHSBC · OAHSBC interview questions
- Find Minimum City HopsAmazon · OA