Binary Tree Traversals
Write a DFS helper that appends the current node before, between, or after visiting children depending on which traversal you are building.
Return the inorder, preorder, and postorder traversals of a binary tree.
Tagged with dfs
Write a DFS helper that appends the current node before, between, or after visiting children depending on which traversal you are building.
Return the inorder, preorder, and postorder traversals of a binary tree.
Scan the grid cell by cell. When you find unvisited land, increment the island count and run DFS or BFS to mark every connected land cell as visited.
Count how many islands of connected land exist in a grid of '1' and '0' values.