Supply Path Optimization
Updated
Problem statement
An ad-tech supply network is represented by a connected undirected graph. Each node is a supply partner, each connection is a direct business relationship, and node 0 represents InMobi.
A connection is critical when removing that single edge increases the number of connected components. Find every critical connection.
Return each critical connection as a pair [u, v] with u < v. Sort the pairs lexicographically, first by u and then by v.
- If the graph has at least one connection and every connection is critical, return
[[-1]]. - If no connection is critical, return an empty list.
Function
criticalConnections(n: int, connections: List<List<Integer>>) → List<List<Integer>>Examples
Example 1
n = 4connections = [[0,1],[1,2],[2,0],[1,3]]return = [[1,3]]Removing [1, 3] disconnects node 3. Every other connection belongs to a cycle, so removing any one of them leaves the graph connected.
Constraints
1 <= n <= 10^5n - 1 <= connections.length <= 2 * 10^5connections[i].length = 20 <= connections[i][0], connections[i][1] < n- The graph is connected.
More InMobi Online Assessment questions
- Validate a Bracket SequenceOA · Seen Oct 2026
- Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
- Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
- Minimum Service Cold StartsOA · Seen Oct 2026
- Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
- Connected Components with Divisor ThresholdOA · Seen Aug 2026
- Maximize Impression ValueOA · Seen Aug 2026
- Delivery ServiceOA · Seen Jun 2026
- Shared InterestOA · Seen Jun 2026
- Temporal AnomaliesOA · Seen Jun 2026
Similar questions at other companies
- Base Unit ConversionsAdobe · OAAdobe interview questions
- Part 1: The Narrowest KeyScale AI · OAScale AI interview questions
- Minimum Unreachable WarehousesVisa · OAVisa interview questions
- Minimum Cleaning Robot RunsHSBC · OAHSBC interview questions
- Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Maximum Data Transfer TimeMicrosoft · OAMicrosoft interview questions
- Validate a DFS Traversal OrderRippling · OARippling interview questions
- Converging Maze: Largest Sum CycleJuspay · OA
- Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN
- Detect a Cycle in Directed Hate RelationshipsArcesium · OAArcesium interview questions