Created
May 13, 2024 15:32
-
-
Save igavrysh/1371b1ca9d45252dd5ac1d674de6a910 to your computer and use it in GitHub Desktop.
Leetcode 1928. Minimum Cost to Reach Destination in Time Attempt#1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1928. Minimum Cost to Reach Destination in Time | |
https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time | |
*/ | |
class Solution { | |
public int minCost(int maxTime, int[][] edges, int[] passingFees) { | |
int src = 0; | |
int n = 0; | |
for (int[] e : edges) { | |
dst = Math.max(dst, Math.max(e[0], e[1])+1); | |
} | |
HashSet<Integer>[] G = new HashSet[n]; | |
for (int[] e: edges) { | |
HashSet<Integer> set0 = G.get(e[0]); | |
if (set0 == null) { | |
set0 = HashSet<Integer>(); | |
G[e[0]] = set0; | |
} | |
G[e[0]].add(e[1]); | |
HashSet<Integer> set1 = G.get(e[1]); | |
if (set1 == null) { | |
set1 = HashSet<Integer>(); | |
G[e[1]] = set1; | |
} | |
G[e[1]].add(e[0]); | |
} | |
int[] costTo = new int[n]; | |
int[] timeTo = new int[n] | |
PriorityQueue<int[]> q = new PriorityQueue<int> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment