The Remove Methods From Project interview question models a software project as a directed graph where each method (node) may invoke other methods (directed edges). Given a "suspicious" method node, you must determine which methods can be safely removed — specifically, all methods that are exclusively reachable from the suspicious method and cannot be reached from any other "clean" method. Methods reachable from clean sources must be retained.
Bloomberg asks this graph problem because it mirrors real-world software analysis tasks: dead code elimination, dependency pruning, and refactoring. It tests graph traversal (BFS or DFS) combined with reachability analysis. Candidates must think carefully about the direction of edges and the distinction between "reachable only from suspicious" vs "reachable from clean methods too."
The pattern is two-pass graph traversal (BFS/DFS). First, find all nodes reachable from the suspicious node using a forward traversal. Second, find all nodes reachable from each clean node (all nodes except the suspicious one) using another BFS/DFS. A node should be removed if it is in the suspicious reachable set but NOT in the clean reachable set. Nodes reachable from both sets must be kept.
Methods: 0, 1, 2, 3, 4. Suspicious: 1. Edges: 0→2, 1→2, 1→3, 3→4.
Remove: {1, 3, 4}. Keep: {0, 2}.
For the Remove Methods From Project coding problem, the BFS and graph interview pattern with reachability analysis is the key. Practice building the adjacency list and running two BFS passes clearly. Bloomberg interviewers appreciate candidates who articulate the two-pass strategy before coding: "First I find what the suspicious method can reach, then I find what clean methods can reach, and remove the difference." This structured approach signals clarity of thought.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Flower Planting With No Adjacent | Medium | Solve | |
| Keys and Rooms | Medium | Solve | |
| Reorder Routes to Make All Paths Lead to the City Zero | Medium | Solve | |
| Unit Conversion I | Medium | Solve | |
| All Paths From Source to Target | Medium | Solve |