Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional
Problem: A bottleneck path from vertex 0 to vertex 4 minimises the largest edge weight used. Using the undirected edges 0-1 (7), 1-2 (3), 2-4 (9), 0-3 (4), 3-2 (6), 3-4 (8), what is the minimum possible value of the largest edge on a 0→4 path?
- A. 12
- B. 8
- C. 9
- D. 4
Correct answer: B. 8
Sort edges and add them until 0 and 4 connect (or read the MST path): 0-3-4 uses edges 4 and 8, so the bottleneck is 8. The shortest-sum view of the same path gives 12, routes through vertex 2 must use the 9-edge, and maximising the smallest edge instead (widest-path confusion) gives 4.
More Coding Interview Problems questions
- Problem: A DAG has 4 vertices with edges 0→2 and 1→2 and 2→3 (vertices 0, 1 have no incoming arcs). How many distinct topological orders…
- Problem: In the undirected graph on vertices 0–4 with edges 0-1, 0-2, 1-2, 1-3, 2-3, 3-4, how many Hamiltonian paths exist (paths that…
- Problem: On a rooted tree (root 1) with children: 1: [2, 3], 2: [4, 5, 6], 3: [7], 5: [8, 9]. How many nodes have exactly 2 descendants…
- Problem: A binary tree is encoded in preorder with '#' for a missing child: "1,2,#,#,3,4,#,#,5,#,#". How many leaves (nodes with two…
- Problem: Count the palindromic substrings of length exactly 4 in the string "aabbaabbaa".
- Problem: How many distinct two-letter substrings does "mississippi" contain?