MicrosoftSoftware Engineer · OnsiteCodemia practiceCount shortest distance in graph
Given a weighted, undirected graph represented as an adjacency list, write a function to compute the shortest distance between two specified nodes. The function should take the graph, the starting node, and the target node as input and return the shortest distance as an integer. If there is no path between the nodes, return -1.
Medium
Coding & Algorithms