As reported: Microsoft online assessment (Feb 2025), question 1:
Ndistricts, arraysAandB(roadijoins districtsA[i]andB[i]) and the hospital districtsH. Return the time to reach the farthest district from a hospital, where crossing from one district to the next takes one minute; return-1if some district cannot be reached.
There are n districts numbered 1 to n. Road i connects districts A[i] and B[i] in both directions, and crossing a road takes one minute. Hospitals are in the districts listed in H.
From every district, an ambulance comes from the nearest hospital. Return the largest of these travel times over all districts — or -1 if some district cannot be reached from any hospital.
Example 1
n = 6, A = [1,1,2,3,3,5], B = [6,2,3,4,5,6], H = [1,4] -> 2
District 5 is two roads away from both hospitals (4–3–5, 1–6–5); every other district is at most one road from a hospital.
Example 2
n = 6, A = [1,2,3,3], B = [2,3,4,5], H = [1,4] -> -1
District 6 has no roads.
Example 3
n = 3, A = [1], B = [2], H = [1,2,3] -> 0
Every district has a hospital.
Constraints: 1 ≤ n ≤ 10^5; 0 ≤ A.length = B.length ≤ 2 · 10^5; 1 ≤ A[i], B[i] ≤ n; 1 ≤ H.length ≤ n, 1 ≤ H[j] ≤ n. Roads may repeat or join a district to itself.
Code runner format: one JSON value per line: n, A, B, H. Implement farthestFromHospital(n, A, B, H); the harness prints the result.