2
public int findTheCity(int n, int[][] edges, int distanceThreshold) {3
int[][] graph = new int[n][n];4
for (int[] row : graph) Arrays.fill(row, Integer.MAX_VALUE);6
for (int i = 0; i < n; i++) graph[i][i] = 0;8
for (int[] edge : edges) {9
graph[edge[0]][edge[1]] = edge[2];10
graph[edge[1]][edge[0]] = edge[2];13
for (int k = 0; k < n; k++) {14
for (int i = 0; i < n; i++) {15
for (int j = 0; j < n; j++) {16
if (graph[i][k] != Integer.MAX_VALUE && graph[k][j] != Integer.MAX_VALUE) {17
if (graph[i][k] + graph[k][j] < graph[i][j]) graph[i][j] = graph[i][k] + graph[k][j];24
int city = Integer.MAX_VALUE;27
for (int i = 0; i < n; i++) {29
for (int j = 0; j < n; j++) {30
if (i != j && graph[i][j] <= distanceThreshold) current++;32
if (current <= city) {