You are given an integer n representing the number of nodes in a directed weighted graph, labeled from n
You are also given:
A edges where edges[i] = [] indicates a directed edge from node
An integer power representing the initial power available for traversal.
An integer array cost of length n, where cost[i] is the amount of power consumed when leaving node i.
Two integers source and target.
A signal starts at source with power units of power. To traverse from a node u to an adjacent node v, the signal consumes cost[u] power. The destination node target does not consume any power upon arrival. The total power consumed along any path cannot exceed power.
If source == target, the time taken is
Find a path from source to target that minimizes the total traversal time. If there are multiple such paths with the same minimum time, choose the one that maximizes the remaining power.
Return an integer array [] containing the minimum time to reach target and the maximum remaining power. If no valid path exists from source to target, return [].
Constraints:
n
edges.length
edges[i] = []
n
power
cost.length n
cost[i]
source, target n
You are given an integer n representing the number of nodes in a directed weighted graph, labeled from n
You are also given:
A edges where edges[i] = [] indicates a directed edge from node
An integer power representing the initial power available for traversal.
An integer array cost of length n, where cost[i] is the amount of power consumed when leaving node i.
Two integers source and target.
A signal starts at source with power units of power. To traverse from a node u to an adjacent node v, the signal consumes cost[u] power. The destination node target does not consume any power upon arrival. The total power consumed along any path cannot exceed power.
If source == target, the time taken is
Find a path from source to target that minimizes the total traversal time. If there are multiple such paths with the same minimum time, choose the one that maximizes the remaining power.
Return an integer array [] containing the minimum time to reach target and the maximum remaining power. If no valid path exists from source to target, return [].
Constraints:
n
edges.length
edges[i] = []
n
power
cost.length n
cost[i]
source, target n