Skip to content

Instantly share code, notes, and snippets.

@igavrysh
Created May 13, 2024 15:32
Show Gist options
  • Save igavrysh/1371b1ca9d45252dd5ac1d674de6a910 to your computer and use it in GitHub Desktop.
Save igavrysh/1371b1ca9d45252dd5ac1d674de6a910 to your computer and use it in GitHub Desktop.
Leetcode 1928. Minimum Cost to Reach Destination in Time Attempt#1
/*
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