Top 50 dfs Interview Questions
The most frequently asked dfs questions across all roles and companies, ranked by real interview frequency. Updated daily.
Detect whether a directed dependency graph of startup tasks contains a cycle using DFS or topological ordering.
AqrXXiaomi Technology
Lucid MotorsUse DFS with recursion-state tracking to detect whether a directed dependency graph contains a cycle.
Altana
Zendesk
FukuCount four-directionally connected islands in a 2D grid using BFS or DFS.
Use iterative DFS coloring to detect circular dependencies in an Applied Intuition simulation module graph.
Applied Intuition
KLA
NextdoorReturn a deterministic build order for Samsung Ads components using Kahn's topological sort, or report a dependency cycle.
Samsung Ads
Swiggy
RobloxFind the lowest common ancestor of two nodes in an Ancestry pedigree tree using depth-first search.
Zocdoc
WalmartUse topological sorting to detect course dependency cycles and return a valid completion order.
Snap
GooglePPiramal FinanceReverse every binary tree level by swapping each node's left and right children using depth-first traversal.
MetaFFreelancer
Google CloudSign up to see every question
Create a free account to unlock this list and practice real interview questions.