3
double frogPosition(int n, vector<vector<int>> &edges, int t, int target) {4
unordered_map<int, vector<int>> adjList;5
for (const auto &edge : edges) {6
adjList[edge[0]].push_back(edge[1]);7
adjList[edge[1]].push_back(edge[0]);11
queue<pair<int, double>> Q;14
vector<int> visited(n + 1, false);16
while (not Q.empty()) {25
double prob = pp.second;29
// Count the unvisited nbr31
for (auto &nbr : adjList[node]) {32
if (not visited[nbr]) nbrCount++;36
if (time == t) return prob;38
// Check if any unvisited ? if yes, then frog would jump there and39
// not be able to jump back here40
if (nbrCount > 0) return 0.0;42
// else return the same prob47
for (auto &nbr : adjList[node]) {48
if (not visited[nbr]) {49
// update the prob as it will be divided by number of nbr50
Q.push({nbr, (prob * (1.0 / nbrCount))});