Find the Path
Updated
Problem statement
Given a graph of N nodes named with 1 to N and M bidirectional weighted edges. Find the path from 1 to N such that weight of maximum in the path is minimum and the number of edges in path won't exceed K.
Function
findThePath(N: int, edges: int[][], K: int) → intExamples
Example 1
N = 4edges = [[1, 2, 4], [1, 3, 2], [2, 4, 5], [2, 3, 6]]K = 3return = 5Note: I'm more than happy to make modifications if anything in the input seems incorrect. You can reach me in our Discord group! 😊 Possible routes from 1 to 4 is [1->2->3, 1->3->2->4] As the maximum in path 1 -> 2 -> 4 is 5 on the edge 2->4, while in 1->3->2->4 is 6 at edge 3->2.
More LinkedIn interview questions
- Allocate Mailboxes with Squared DistanceONSITE INTERVIEW · Seen Nov 2026
- Find Leaves of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Max Points on a LineONSITE INTERVIEW · Seen Nov 2026
- Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
- Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
- Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
- Sqrt(x)PHONE SCREEN · Seen Nov 2026
- Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
- Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
- Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Sum Dynamic Weighted Tree DistancesJuspay · OA
- Minimum Fuel Cost Between CitiesMicrosoft · OAMicrosoft interview questions
- Drone Delivery with Battery Swap StationsCisco · OACisco interview questions
- Optimal TransferSuperhuman · OASuperhuman interview questions
- Minimum Travel Time With Periodic Fast RoadsAdobe · OAAdobe interview questions
- Energy CrisisRubrik · OARubrik interview questions
- Avoiding the Obstacles (IMC Sydney 🦪)IMC Trading · OAIMC Trading interview questions
- Compute Number of LocationsMoney Forward · OA
- Best Telescope SiteAtlassian · OAAtlassian interview questions
- Cheapest Flight with Its PathAirbnb · OA · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions