You are given a weighted, undirected, and connected graph with V
vertices. The graph is represented as an adjacency list adj
where adj[i]
is a list of lists. Each list contains two integers: the first is a connected vertex j
and the second is the weight of the edge from i
to j
.
Given a source vertex S
, the task is to find the shortest distance from the source to every other vertex. The output should be a list of integers denoting these shortest distances.