13Explain BFS and DFS and when to use each, then detect a cycle in a graph.▼mediumGoogleMetaAmazon1 replies○ sign inGraph traversal underpins a huge class of interview problems. The signal is knowing the BFS-vs-DFS tradeoff (shortest path vs memory shape) and applying it cleanly, then handling the directed-vs-undirected cycle gotcha most candidates miss.Open full answer →
30Topological sort: order tasks with dependencies (and detect cycles).▼mediumGoogleMetaAmazon1 replies◆ premiumTopological sort orders a DAG so dependencies come first, the backbone of build systems, schedulers, and ML/data pipeline DAGs. The signal is Kahn's algorithm (or DFS) plus cycle detection. Here is the answer.Open full answer →
31Union-Find (Disjoint Set Union): connectivity and grouping.▼mediumGoogleMetaAmazon1 replies◆ premiumUnion-Find answers 'are these in the same group?' near-instantly and powers connected-components, cycle detection, and clustering. The signal is path compression plus union by rank for near-O(1) operations. Here is the answer.Open full answer →
69Course Schedule: can you finish all courses given prerequisites (cycle detection)?▼medium★ EssentialGoogleMetaAmazon1 replies◆ premiumCourse Schedule reduces to one question: is the prerequisite graph a DAG? The signal is spotting the graph framing and using topological sort or DFS to detect a cycle. Here is the answer.Open full answer →
105Dijkstra's algorithm: shortest paths from a source in a weighted graph.▼mediumGoogleAmazonUber2 replies◆ premiumDijkstra finds single-source shortest paths in O((V+E) log V) with a min-heap, the backbone of routing and network latency problems. The signal is why it needs non-negative weights and how lazy deletion keeps the heap simple. Here is the answer.Open full answer →
106Bellman-Ford: shortest paths with negative edges and negative-cycle detection.▼mediumGoogleAmazonMicrosoft1 replies◆ premiumBellman-Ford handles negative edge weights that break Dijkstra and detects negative cycles, the basis of currency-arbitrage problems. The signal is the V-1 relaxation rounds and the extra Vth round that flags a negative cycle. Here is the answer.Open full answer →
107Floyd-Warshall: all-pairs shortest paths with a three-loop dynamic program.▼mediumGoogleAmazonMicrosoft2 replies◆ premiumFloyd-Warshall computes shortest paths between every pair of nodes in O(V cubed) with a tight three-line triple loop. The signal is the intermediate-node DP order and why k must be the outer loop. Here is the answer.Open full answer →
66What are Graph Neural Networks (GNNs), and how does message passing work?▼hardGoogleMetaPinterest2 replies◆ premiumGNNs power recommendations, fraud, and molecule modeling by learning over graph structure. The signal is the message-passing mechanism, why k-hop matters, and why you keep them shallow. Here is the answer.Open full answer →
14How do you query hierarchical data (org charts, category trees) in SQL with a recursive CTE?▼mediumSnowflakeDatabricksMicrosoft2 replies○ sign inHierarchies (org charts, bill-of-materials, category trees) need recursion, and a self-join only goes one level deep. The signal is the recursive CTE with its anchor plus recursive members, and knowing how it terminates.Open full answer →
44Find shortest paths and detect cycles in a graph stored as edges, using a recursive CTE.▼hardSnowflakeDatabricksGoogle1 replies◆ premiumAn org-chart recursion walks a tree, but a general graph has multiple paths and back-edges. The signal is accumulating the visited path to prune cycles and ranking paths by cost to get the shortest one.Open full answer →
37Design a 'People You May Know' (friend/connection recommendation) system.▼hardMetaLinkedInGoogle1 replies◆ premiumPYMK is graph recommendation at billion-node scale. The interviewer is screening for one instinct: do you generate candidates from the social graph, or naively try to score all pairs? Here is the design that survives the follow-ups.Open full answer →
83Design a misinformation / fake-news detection system at scale.▼hardMetaGoogleMicrosoft1 replies◆ premiumTruth is not a label you can train on cheaply, and adversaries adapt the moment you ship. A strong answer fuses content, graph, and behavioral signals, puts humans in the loop where precision matters, and treats adversarial drift as a permanent operating condition, not a one-time training problem.Open full answer →