🌳 Trees & Graphs Problems

Master binary trees, BST, graph traversal, topological sort, and tree/graph algorithms

Return the level order traversal of a binary tree (values by level from left to right).

java

Determine if a binary tree is a valid BST.

java

Find the lowest common ancestor (LCA) of two nodes in a binary tree.

java

Count the number of islands in a 2D grid (1 = land, 0 = water).

java

Determine if you can finish all courses given prerequisites (detect cycle in DAG).

java

Return a deep copy of a connected undirected graph.

java

Find the maximum path sum in a binary tree. Path can start and end at any node.

java

Design an algorithm to serialize and deserialize a binary tree.

java

Trees & Graphs Patterns