12Number of islands: count connected regions in a grid▼medium★ EssentialMetaPalantirxAI1 replies○ sign inThe canonical grid question, and the template for every flood-fill, shortest-path, and region-labeling variant FDE loops throw at you. BFS vs DFS vs union-find: here's which to write and which to merely mention.Open full answer →
13Shortest path in a grid with obstacles▼mediumMetaxAIPalantir1 replies○ sign inThe follow-up to number-of-islands, and the question where candidates reveal whether they understand WHY BFS finds shortest paths. Plus the two variants (weights, eliminating obstacles) that decide hard-screen outcomes at xAI.Open full answer →
14Word search: does a word exist as a path of adjacent cells in a letter grid?▼mediumMetaPalantirxAI1 replies○ sign inThe third member of the grid trilogy, and the one that tests backtracking discipline: marking, unmarking, and the early-exit pruning that turns a timeout into a pass.Open full answer →
90Simulate an infection spreading across a grid over time▼mediumOpenAIGoogleAmazon1 replies◆ premiumA grid where some cells start infected, and each step every infected cell infects its orthogonal neighbors. How many steps until everything is infected, or -1 if some cell is unreachable? This is rotting oranges in disguise, and the multi-source BFS framing is what they want to hear.Open full answer →