Skip to content

Commit

Permalink
Solution to today's problem
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Feb 23, 2024
1 parent aeb23dc commit f00f1f6
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
*/
public class Problem0787 extends LeetcodeProblem {

private static final int INF = 0x3f3f3f3f;

public int findCheapestPrice(int _n, int[][] _flights, int _src, int _dst, int _k) {
int inf = 0x3f3f3f3f;
int[] dist = new int[_n];
int[] backup = new int[_n];
Arrays.fill(dist, INF);
Arrays.fill(dist, inf);
dist[_src] = 0;
for (int i = 0; i < _k + 1; i++) {
System.arraycopy(dist, 0, backup, 0, _n);
Expand All @@ -25,7 +24,7 @@ public int findCheapestPrice(int _n, int[][] _flights, int _src, int _dst, int _
dist[t] = Math.min(dist[t], backup[f] + p);
}
}
return dist[_dst] == INF ? -1 : dist[_dst];
return dist[_dst] == inf ? -1 : dist[_dst];
}

}

0 comments on commit f00f1f6

Please sign in to comment.