bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 2492. Minimum Score of a Path Between Two Cities

2492. Minimum Score of a Path Between Two Cities

Leetcode Solutions

Approach: Breadth First Search

  1. Create an adjacency list adj to represent the graph.
  2. Initialize a queue q and add node 1 to it.
  3. Initialize a visit array to keep track of visited nodes.
  4. Initialize answer with the maximum possible value.
  5. While the queue is not empty: a. Pop the front node from the queue. b. Iterate over all its connected edges. c. Update answer with the minimum of the current answer and the edge weight. d. If the connected node is not visited, mark it as visited and add it to the queue.
  6. Return answer as the result.
UML Thumbnail

Approach: Depth First Search

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...