Gossip Consensus on the Maximum Value
Updated
Problem statement
Given values and edges, return [globalMaximum, roundsUntilEveryNodeKnowsIt]: the largest value in the network and the number of rounds until every node knows it.
Node i starts out knowing values[i]. edges lists the links of a connected, undirected network. In each round, all nodes update at the same time: each node takes the largest value that it or any of its neighbors knew at the start of that round.
Function
gossipMaximum(values: int[], edges: int[][]) → int[]Examples
Example 1
values = [3,9,2,5]edges = [[0,1],[1,2],[2,3]]return = [9,2]The largest value, nine, starts at node 1. It moves one link per round, so it reaches the farthest node, node 3, after two rounds.
Constraints
1 <= values.length <= 10^5.- The graph is connected.
More Bloomberg LP Onsite Interview questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Priority-Aware Dependent Task OrderGoogle · ONSITE INTERVIEWGoogle interview questions
- Count Islands from Streaming RowsAmazon · ONSITE INTERVIEW
- Concurrent Web Crawler SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Deterministic Secret Santa AssignmentShopify · PHONE SCREENShopify interview questions
- Corporation Reporting LinesMicrosoft · PHONE SCREENMicrosoft interview questions
- Detect a Deadlock from Lock LogsHelm.ai · PHONE SCREEN
- Retryable URL MazeRamp · PHONE SCREENRamp interview questions
- Minimize Malware Spread by Removing a NodeVisa · OAVisa interview questions
- Minimize Malware Spread by Removing a NodeAkuna Capital · OAAkuna Capital interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)