Satellite Network Message Propagation
Updated
Problem statement
Maintain an undirected satellite network and simulate message propagation.
SATELLITE idconnects a new satellite. If the ID already exists, outputErrDuplicateSatellite: id.RELATION a badds a two-way connection.MESSAGE m id1 ... idmsimultaneously notifies the listed satellites and runs one complete propagation.
An instruction that references nonexistent satellites outputs ErrInvalidSatellite: id once for every distinct invalid ID in left-to-right order, then makes no state change.
Propagation timing
- Each notified satellite considers direct neighbors in increasing ID order.
- It skips neighbors already known to be notified. It never tries to notify the satellite that notified it.
- One forwarding attempt takes exactly
10seconds, and one sender can have only one attempt in flight. - Two senders may attempt the same target concurrently. Even if another attempt finishes first or at the same time, each in-flight sender still spends its full
10seconds. - After a sender finishes all required attempts, it spends
30seconds processing and reports back. - Reports are ordered by time, then by smaller satellite ID.
Return every callback string in invocation order.
Function
simulateSatelliteNetwork(instructions: String[]) → String[]Examples
Example 1
instructions = ["SATELLITE 1","SATELLITE 2","SATELLITE 3","RELATION 2 1","MESSAGE 1 2"]return = ["SatelliteReportedBack: 1","SatelliteReportedBack: 2"]Satellite 2 forwards to 1 for 10 seconds. Both finish processing at time 40, so ID 1 reports first.
Example 2
instructions = ["SATELLITE 1","SATELLITE 2","SATELLITE 3","SATELLITE 4","SATELLITE 5","RELATION 1 3","RELATION 1 2","RELATION 2 5","RELATION 3 2","RELATION 3 4","RELATION 3 5","MESSAGE 2 1 3"]return = ["SatelliteReportedBack: 1","SatelliteReportedBack: 2","SatelliteReportedBack: 3","SatelliteReportedBack: 4","SatelliteReportedBack: 5"]Satellites 1 and 3 start together. Concurrent attempts to 2 finish at time 10; all reports at time 50 are ordered by ID.
Constraints
0 <= satelliteId < 2^161 <= instructions.length <= 10^5- Each instruction has the documented valid token format.
- Repeated relationships and duplicate IDs within one
MESSAGEinstruction are idempotent.
More Optiver Online Assessment questions
- Power Cell BankOA · Seen Nov 2026
- Overheat Prevention ControllerOA · Seen Nov 2026
- Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026
- Fastest Average Speed over a Rolling KilometerOA · Seen Sep 2026
- Multi-Level Inventory Storage SystemOA · PHONE SCREEN · Seen Aug 2026
- Proportional Momentum Investment StatisticsOA · Seen Aug 2026
- Count Bounded Share TransactionsOA · Seen Aug 2026
- Count Ordered Size SequencesOA · Seen Aug 2026
- Profitable Currency Exchange CycleOA · Seen Aug 2026
- Construct Binary Tree S-ExpressionOA · Seen Jul 2026
Similar questions at other companies
- Concurrent Web Crawler SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Minimize Malware Spread by Removing a NodeVisa · OAVisa interview questions
- Minimize Malware Spread by Removing a NodeAkuna Capital · OAAkuna Capital interview questions
- Maximum Safeness of a Grid PathIntuit · OAIntuit interview questions
- Course Schedule IIChainalysis · OAChainalysis interview questions
- Reaching Points with Perfect-Square ObstaclesIMC Trading · OAIMC Trading interview questions
- Fuel Route with Fewest Station VisitsGoogle · ONSITE INTERVIEWGoogle interview questions
- Dynamic Broadcast TimesNetflix · PHONE SCREENNetflix interview questions
- Shortest Path Around Moving ParadesZip · PHONE SCREENZip interview questions
- Course Schedule IIAmazon · PHONE SCREEN · ONSITE INTERVIEW