Amazon Depth First Search Questions

218 depth first search problems asked at Amazon interviews

Easy (33)Medium (142)Hard (43)

Questions

TitleDifficulty
Number of IslandsMedium
Course ScheduleMedium
Lowest Common Ancestor of a Binary TreeMedium
Course Schedule IIMedium
Word SearchMedium
Binary Tree Maximum Path SumHard
Serialize and Deserialize Binary TreeHard
Binary Tree Right Side ViewMedium
All Nodes Distance K in Binary TreeMedium
Concatenated WordsHard
Flood FillEasy
Validate Binary Search TreeMedium
Diameter of Binary TreeEasy
Number of ProvincesMedium
Evaluate DivisionMedium
Balanced Binary TreeEasy
Symmetric TreeEasy
Maximum Depth of Binary TreeEasy
Same TreeEasy
Vertical Order Traversal of a Binary TreeHard
Maximum Width of Binary TreeMedium
Lowest Common Ancestor of a Binary Search TreeMedium
Surrounded RegionsMedium
Pacific Atlantic Water FlowMedium
Populating Next Right Pointers in Each NodeMedium
Kth Smallest Element in a BSTMedium
Cheapest Flights Within K StopsMedium
House Robber IIIMedium
Invert Binary TreeEasy
Critical Connections in a NetworkHard
Binary Tree Inorder TraversalEasy
Accounts MergeMedium
Making A Large IslandHard
Max Area of IslandMedium
Clone GraphMedium
Recover Binary Search TreeMedium
Number of Distinct IslandsMedium
Amount of Time for Binary Tree to Be InfectedMedium
Alien DictionaryHard
Design Add and Search Words Data StructureMedium
Flatten Binary Tree to Linked ListMedium
Is Graph Bipartite?Medium
Maximum Sum BST in Binary TreeHard
Number of Connected Components in an Undirected GraphMedium
Boundary of Binary TreeMedium
Binary Tree CamerasHard
Find Eventual Safe StatesMedium
Path Sum IIIMedium
Balance a Binary Search TreeMedium
Reconstruct ItineraryHard
Two Sum IV - Input is a BSTEasy
Merge Two Binary TreesEasy
Flatten a Multilevel Doubly Linked ListMedium
Path SumEasy
Binary Search Tree to Greater Sum TreeMedium
Recover a Tree From Preorder TraversalHard
Cousins in Binary Tree IIMedium
Loud and RichMedium
Path Sum IIMedium
Convert BST to Greater TreeMedium
Maximum Difference Between Node and AncestorMedium
Lowest Common Ancestor of a Binary Tree IVMedium
Clone Binary Tree With Random PointerMedium
Most Frequent Subtree SumMedium
Count Unreachable Pairs of Nodes in an Undirected GraphMedium
Find if Path Exists in GraphEasy
Most Stones Removed with Same Row or ColumnMedium
Serialize and Deserialize BSTMedium
Longest Increasing Path in a MatrixHard
Keys and RoomsMedium
MinesweeperMedium
Number of Distinct Islands IIHard
Sum of Root To Leaf Binary NumbersEasy
Number of Operations to Make Network ConnectedMedium
Network Delay TimeMedium
All Paths From Source to TargetMedium
Redundant ConnectionMedium
Flatten Nested List IteratorMedium
Subtree of Another TreeEasy
Binary Tree Vertical Order TraversalMedium
Sum Root to Leaf NumbersMedium
Check for Contradictions in EquationsHard
Path With Maximum Minimum ValueMedium
Two Sum BSTsMedium
Sum of Nodes with Even-Valued GrandparentMedium
Battleships in a BoardMedium
Lexicographical NumbersMedium
Serialize and Deserialize N-ary TreeHard
Nested List Weight SumMedium
Design Search Autocomplete SystemHard
Swim in Rising WaterHard
Construct String from Binary TreeMedium
All Elements in Two Binary Search TreesMedium
Find Distance in a Binary TreeMedium
Find Number of Coins to Place in Tree NodesHard
Minimum Score After Removals on a TreeHard
Delete Leaves With a Given ValueMedium
Insufficient Nodes in Root to Leaf PathsMedium
Distribute Coins in Binary TreeMedium
Reorder Routes to Make All Paths Lead to the City ZeroMedium
Shortest BridgeMedium
Count Servers that CommunicateMedium
Pseudo-Palindromic Paths in a Binary TreeMedium
Construct Binary Tree from StringMedium
Maximum Average SubtreeMedium
Clone N-ary TreeMedium
Equal Tree PartitionMedium
Minimum Operations to Remove Adjacent Ones in MatrixHard
Closest Leaf in a Binary TreeMedium
Binary Tree Preorder TraversalEasy
Island PerimeterEasy
Minimum Fuel Cost to Report to the CapitalMedium
Path With Minimum EffortMedium
Course Schedule IVMedium
Binary Tree Postorder TraversalEasy
Binary Tree PathsEasy
Remove Sub-Folders from the FilesystemMedium
Minimum Height TreesMedium
Minimum Depth of Binary TreeEasy
Populating Next Right Pointers in Each Node IIMedium
Find Duplicate SubtreesMedium
Total Sum of Interaction Cost in Tree GroupsHard
Detect Cycles in 2D GridMedium
Possible BipartitionMedium
Count Good Nodes in Binary TreeMedium
Detonate the Maximum BombsMedium
Sum of Left LeavesEasy
Find Largest Value in Each Tree RowMedium
Trim a Binary Search TreeMedium
Lexicographically Smallest String After Applying OperationsMedium
Maximum Level Sum of a Binary TreeMedium
Maximum Product of Splitted Binary TreeMedium
Range Sum of BSTEasy
Regions Cut By SlashesMedium
Step-By-Step Directions From a Binary Tree Node to AnotherMedium
Water and Jug ProblemMedium
Count the Number of Complete ComponentsMedium
Find Closest Node to Given Two NodesMedium
Cousins in Binary TreeEasy
N-ary Tree Postorder TraversalEasy
Tree DiameterMedium
Last Day Where You Can Still CrossHard
Kill ProcessMedium
Web CrawlerMedium
Jump Game IIIMedium
Smallest String Starting From LeafMedium
Delete Nodes And Return ForestMedium
Average of Levels in Binary TreeEasy
Find Leaves of Binary TreeMedium
Leaf-Similar TreesEasy
Increasing Order Search TreeEasy
Maximum Employees to Be Invited to a MeetingHard
Check if the Rectangle Corner Is ReachableHard
All Ancestors of a Node in a Directed Acyclic GraphMedium
Most Profitable Path in a TreeMedium
Count Univalue SubtreesMedium
Find Bottom Left Tree ValueMedium
Number of Ways to Assign Edge Weights IMedium
Minimum Absolute Difference in BSTEasy
Minimum Edge Reversals So Every Node Is ReachableHard
Mini ParserMedium
Time Needed to Inform All EmployeesMedium
Merge BSTs to Create Single BSTHard
Kth Ancestor of a Tree NodeHard
Minimum Number of Days to Disconnect IslandHard
Graph Valid TreeMedium
The MazeMedium
Binary Tree PruningMedium
Maximum Number of Fish in a GridMedium
Employee ImportanceMedium
N-ary Tree Preorder TraversalEasy
Longest Cycle in a GraphHard
Divide Nodes Into the Maximum Number of GroupsHard
Sentence Similarity IIMedium
Minimum Distance Between BST NodesEasy
Power Grid MaintenanceMedium
Longest Path With Different Adjacent CharactersHard
Closest Binary Search Tree Value IIHard
Longest Absolute File PathMedium
Minimum Time to Collect All Apples in a TreeMedium
Escape a Large MazeHard
Binary Tree TiltEasy
Minimize Malware SpreadHard
Count Nodes Equal to Average of SubtreeMedium
Find Mode in Binary Search TreeEasy
Sum of Distances in TreeHard
Flip Equivalent Binary TreesMedium
Number of EnclavesMedium
Number of Closed IslandsMedium
Longest ZigZag Path in a Binary TreeMedium
Find Elements in a Contaminated Binary TreeMedium
Linked List in Binary TreeMedium
Valid Arrangement of PairsHard
Find a Corresponding Node of a Binary Tree in a Clone of That TreeEasy
Count Nodes With the Highest ScoreMedium
Maximum Number of K-Divisible ComponentsHard
Minimum Score of a Path Between Two CitiesMedium
Binary Tree Longest Consecutive SequenceMedium
Convert Binary Search Tree to Sorted Doubly Linked ListMedium
Delete Duplicate Folders in SystemHard
Maximum Depth of N-ary TreeEasy
Lowest Common Ancestor of Deepest LeavesMedium
Inorder Successor in BSTMedium
The Maze IIMedium
Sort Items by Groups Respecting DependenciesHard
Binary Tree Coloring GameMedium
Sum of Perfect Square AncestorsHard
Print Binary TreeMedium
Smallest Subtree with all the Deepest NodesMedium
Find All People With SecretHard
Operations on TreeMedium
Similar String GroupsHard
Check Knight Tour ConfigurationMedium
Restore the Array From Adjacent PairsMedium
Array NestingMedium
Longest Univalue PathMedium
Properties GraphMedium
Number of Ways to Assign Edge Weights IIHard

Showing 218 questions