Google Depth First Search Questions

241 depth first search problems asked at Google interviews

Easy (34)Medium (148)Hard (59)

Questions

TitleDifficulty
Number of IslandsMedium
Course ScheduleMedium
Binary Tree Maximum Path SumHard
Same TreeEasy
Diameter of Binary TreeEasy
Surrounded RegionsMedium
Word SearchMedium
Pacific Atlantic Water FlowMedium
Apply SubstitutionsMedium
Invert Binary TreeEasy
Number of ProvincesMedium
Lowest Common Ancestor of a Binary TreeMedium
Delete Nodes And Return ForestMedium
Kth Smallest Element in a BSTMedium
Symmetric TreeEasy
Swim in Rising WaterHard
Clone GraphMedium
Binary Tree Inorder TraversalEasy
Longest Increasing Path in a MatrixHard
Serialize and Deserialize Binary TreeHard
Evaluate DivisionMedium
Maximum Depth of Binary TreeEasy
Path With Minimum EffortMedium
Cheapest Flights Within K StopsMedium
Course Schedule IIMedium
Alien DictionaryHard
Network Delay TimeMedium
Redundant ConnectionMedium
Validate Binary Search TreeMedium
Accounts MergeMedium
Vertical Order Traversal of a Binary TreeHard
Find Eventual Safe StatesMedium
Balanced Binary TreeEasy
Number of Closed IslandsMedium
Binary Tree Right Side ViewMedium
Max Area of IslandMedium
Binary Tree PathsEasy
Height of Binary Tree After Subtree Removal QueriesHard
Sum of Distances in TreeHard
Flatten Binary Tree to Linked ListMedium
Reconstruct ItineraryHard
Detonate the Maximum BombsMedium
Find Duplicate SubtreesMedium
Flood FillEasy
Recover Binary Search TreeMedium
Making A Large IslandHard
Remove Sub-Folders from the FilesystemMedium
Graph Valid TreeMedium
Keys and RoomsMedium
House Robber IIIMedium
Regions Cut By SlashesMedium
Binary Tree Vertical Order TraversalMedium
Flatten Nested List IteratorMedium
Longest Absolute File PathMedium
Path Sum IIIMedium
Maximum Level Sum of a Binary TreeMedium
Minimum Absolute Difference in BSTEasy
Minimum Height TreesMedium
All Nodes Distance K in Binary TreeMedium
Number of EnclavesMedium
Two Sum IV - Input is a BSTEasy
Maximum Width of Binary TreeMedium
Binary Tree Preorder TraversalEasy
Island PerimeterEasy
Is Graph Bipartite?Medium
Path SumEasy
Lexicographical NumbersMedium
Maximum Number of K-Divisible ComponentsHard
Count Servers that CommunicateMedium
Minimize Hamming Distance After Swap OperationsMedium
Design Search Autocomplete SystemHard
Lowest Common Ancestor of a Binary Search TreeMedium
Find if Path Exists in GraphEasy
Sum Root to Leaf NumbersMedium
Time Needed to Inform All EmployeesMedium
Find All People With SecretHard
Find Mode in Binary Search TreeEasy
Find Leaves of Binary TreeMedium
Kth Ancestor of a Tree NodeHard
Shortest BridgeMedium
Path With Maximum Minimum ValueMedium
Flip Equivalent Binary TreesMedium
Number of Connected Components in an Undirected GraphMedium
Smallest String Starting From LeafMedium
Populating Next Right Pointers in Each NodeMedium
Design Add and Search Words Data StructureMedium
Cracking the SafeHard
The MazeMedium
Similar String GroupsHard
Implement Magic DictionaryMedium
Most Stones Removed with Same Row or ColumnMedium
Binary Tree Longest Consecutive SequenceMedium
Evaluate Boolean Binary TreeEasy
Redundant Connection IIHard
Closest Nodes Queries in a Binary Search TreeMedium
Disconnect Path in a Binary Matrix by at Most One FlipMedium
Sentence Similarity IIMedium
Check if DFS Strings Are PalindromesHard
Smallest Rectangle Enclosing Black PixelsHard
Critical Connections in a NetworkHard
Water and Jug ProblemMedium
Maximum Employees to Be Invited to a MeetingHard
Deepest Leaves SumMedium
Freedom TrailHard
All Ancestors of a Node in a Directed Acyclic GraphMedium
Minimum Distance Between BST NodesEasy
Couples Holding HandsHard
Closest Binary Search Tree ValueEasy
Last Day Where You Can Still CrossHard
Subtree of Another TreeEasy
Minimum Depth of Binary TreeEasy
Binary Tree Postorder TraversalEasy
Distribute Coins in Binary TreeMedium
Number of Good Leaf Nodes PairsMedium
Binary Tree Coloring GameMedium
Operations on TreeMedium
Closest Binary Search Tree Value IIHard
The Maze IIMedium
Boundary of Binary TreeMedium
Find Root of N-Ary TreeMedium
Throne InheritanceMedium
Minimum Path Cost in a Hidden GridMedium
Path Sum IIMedium
Flatten a Multilevel Doubly Linked ListMedium
Range Sum of BSTEasy
Frog Position After T SecondsHard
Minimum Flips in Binary Tree to Get ResultHard
Binary Tree Longest Consecutive Sequence IIMedium
Longest Univalue PathMedium
Extract Kth Character From The Rope TreeEasy
Maximum Score After Applying Operations on a TreeMedium
Tree DiameterMedium
Find Elements in a Contaminated Binary TreeMedium
Move Sub-Tree of N-Ary TreeHard
Check If Two Expression Trees are EquivalentMedium
Correct a Binary TreeMedium
Change the Root of a Binary TreeMedium
Checking Existence of Edge Length Limited Paths IIHard
Tree of CoprimesHard
Longest Word With All PrefixesMedium
Maximum Product of Splitted Binary TreeMedium
Maximum Sum BST in Binary TreeHard
Recover a Tree From Preorder TraversalHard
Serialize and Deserialize N-ary TreeHard
Employee ImportanceMedium
Nested List Weight SumMedium
Minimum Increments to Equalize Leaf PathsMedium
Step-By-Step Directions From a Binary Tree Node to AnotherMedium
Populating Next Right Pointers in Each Node IIMedium
Detect Cycles in 2D GridMedium
Sum of Left LeavesEasy
Battleships in a BoardMedium
Smallest String With SwapsMedium
Lowest Common Ancestor of Deepest LeavesMedium
Minimize the Maximum Edge Weight of GraphMedium
Delete Leaves With a Given ValueMedium
Divide Nodes Into the Maximum Number of GroupsHard
Cousins in Binary Tree IIMedium
Reverse Odd Levels of Binary TreeMedium
Find Largest Value in Each Tree RowMedium
Balance a Binary Search TreeMedium
Number of Ways to Assign Edge Weights IIHard
Count Good Nodes in Binary TreeMedium
Leaf-Similar TreesEasy
Possible BipartitionMedium
Merge Two Binary TreesEasy
Cousins in Binary TreeEasy
Course Schedule IVMedium
Nested List Weight Sum IIMedium
Average of Levels in Binary TreeEasy
Power Grid MaintenanceMedium
Increasing Order Search TreeEasy
Print Binary TreeMedium
Number of Distinct IslandsMedium
Minimum Score of a Path Between Two CitiesMedium
Sum of Root To Leaf Binary NumbersEasy
Trim a Binary Search TreeMedium
Smallest Subtree with all the Deepest NodesMedium
Coloring A BorderMedium
MinesweeperMedium
Binary Tree CamerasHard
Count Sub IslandsMedium
Count Univalue SubtreesMedium
Serialize and Deserialize BSTMedium
Delete Duplicate Folders in SystemHard
Maximize the Number of Target Nodes After Connecting Trees IMedium
All Paths From Source to TargetMedium
Find Weighted Median Node in TreeHard
Maximize the Number of Target Nodes After Connecting Trees IIHard
Sort Items by Groups Respecting DependenciesHard
Count Nodes Equal to Average of SubtreeMedium
Longest Cycle in a GraphHard
Amount of Time for Binary Tree to Be InfectedMedium
Check if the Rectangle Corner Is ReachableHard
Find Minimum Diameter After Merging Two TreesHard
Univalued Binary TreeEasy
Reorder Routes to Make All Paths Lead to the City ZeroMedium
Linked List in Binary TreeMedium
Count Unreachable Pairs of Nodes in an Undirected GraphMedium
Find Bottom Left Tree ValueMedium
Maximum Number of Fish in a GridMedium
N-ary Tree Postorder TraversalEasy
N-ary Tree Preorder TraversalEasy
Restore the Array From Adjacent PairsMedium
Minimum Fuel Cost to Report to the CapitalMedium
K-th Largest Perfect Subtree Size in Binary TreeMedium
Convert BST to Greater TreeMedium
Number of Distinct Islands IIHard
Count the Number of Complete ComponentsMedium
Inorder Successor in BSTMedium
Longest Special Path IIHard
Find Closest Node to Given Two NodesMedium
Maximum Profit from Trading Stocks with DiscountsHard
Maximum Number of Accepted InvitationsMedium
Number of Operations to Make Network ConnectedMedium
Binary Search Tree to Greater Sum TreeMedium
Check if There is a Valid Path in a GridMedium
Maximum Partition FactorHard
Most Profitable Path in a TreeMedium
Add One Row to TreeMedium
Validate Binary Tree NodesMedium
Check Knight Tour ConfigurationMedium
Maximize Amount After Two Days of ConversionsMedium
Contain VirusHard
Closest Node to Path in TreeHard
Minimize Malware SpreadHard
Web Crawler MultithreadedMedium
Find All Groups of FarmlandMedium
Shortest Path in a Hidden GridMedium
The Maze IIIHard
Count Islands With Total Value Divisible by KMedium
Minimum Score After Removals on a TreeHard
Binary Tree Upside DownMedium
Escape a Large MazeHard
Sum of Perfect Square AncestorsHard
Count Paths That Can Form a Palindrome in a TreeHard
Minimum Number of Days to Disconnect IslandHard
Merge BSTs to Create Single BSTHard
Reachable Nodes With RestrictionsMedium
Valid Arrangement of PairsHard
Minimum Edge Reversals So Every Node Is ReachableHard

Showing 241 questions