Maximum-Efficiency Transmission Path
Updated
Problem statement
An undirected transmission network has n nodes numbered from 0 to n - 1. Each pair in edges identifies one transmission line, and the value at the same index in efficiencies is a number from 0 to 1.
The efficiency of a path is the product of its line efficiencies. Return the maximum efficiency of any path from source to destination. Return 0.0 when no path exists.
Function
maxEfficiency(n: int, edges: int[][], efficiencies: double[], source: int, destination: int) → doubleExamples
Example 1
n = 3edges = [[0,1],[1,2],[0,2]]efficiencies = [0.5,0.5,0.2]source = 0destination = 2return = 0.25The two-line path has efficiency 0.5 times 0.5, which exceeds the direct line's 0.2.
Example 2
n = 4edges = [[0,1],[2,3]]efficiencies = [0.75,0.5]source = 0destination = 3return = 0.0The destination is in a different connected component.
Constraints
1 <= n <= 100000.0 <= edges.length <= 200000, andedges.length == efficiencies.length.- Every edge contains two distinct valid node indices; parallel lines may exist.
0.0 <= efficiencies[i] <= 1.0.
Source note: The source image is a source-neutral excerpt of the author-reported prompt.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
- Cheapest Flights Within K StopsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Shortest Paths in a Nonnegative Directed GraphNation with NaMo · PHONE SCREEN
- Dijkstra Shortest Paths in a Weighted Undirected GraphGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
- Shortest Path with Directional Move CostsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
- Shortest-Path Distances with DijkstraApple · PHONE SCREENApple interview questions
- Fastest Flight Route Between AirportsAirbnb · PHONE SCREENAirbnb interview questions
- Dynamic Broadcast TimesNetflix · PHONE SCREENNetflix interview questions
- Path With Maximum ProbabilitySalesforce · ONSITE INTERVIEWSalesforce interview questions
- Minimum Stress PathWalmart · OAWalmart interview questions