Recursion

Recursion & Backtracking

Master recursive problem solving, backtracking, and exploring all solution possibilities.

All Paths From Source to Target

Find all possible paths from source node to target node in a directed acyclic graph (DAG)

Binary Tree Inorder Traversal

Traverse a binary tree in inorder (left -> root -> right)

Binary Tree Preorder Traversal

Traverse a binary tree in preorder (root -> left -> right)

Boundary Traversal of Binary Tree

Traverse the boundary of a binary tree in anti-clockwise direction.

Construct Binary Tree from Preorder and Inorder Traversal

Construct a binary tree from preorder and inorder traversal sequences.

Convert Sorted Array to Binary Search Tree

Convert a sorted array to a height-balanced binary search tree.

Count and Say

Generate the nth term of the count-and-say sequence.

Count Good Nodes in Binary Tree

Count the number of nodes in a binary tree where the path from root to that node has no nodes with values greater than the current node.

Decode String

Decode a string encoded with the format k[encoded_string].

Depth-First Search (DFS)

Implement depth-first search traversal for graphs

Diameter of Binary Tree

Find the diameter (longest path) of a binary tree.

Fibonacci Numbers

Calculate the nth Fibonacci number using dynamic programming

Flatten Binary Tree to Linked List

Flatten a binary tree into a linked list in-place using preorder traversal.

Flatten Multilevel Linked List

Flatten a multilevel doubly linked list into a single level

Generate Permutations

Generate all possible permutations of a given string.

Invert Binary Tree

Invert (mirror) a binary tree by swapping left and right children

Lowest Common Ancestor

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

Maximum Depth of Binary Tree

Find the maximum depth (height) of a binary tree

Maximum Path Sum

Find the maximum path sum in a binary tree.

Merge Two Sorted Lists

Merge two sorted linked lists into one sorted linked list

Path Sum

Check if there exists a root-to-leaf path with given sum.

Postorder Traversal

Traverse binary tree in postorder (left, right, root)

Print All Root-to-Leaf Paths

Print all root-to-leaf paths in a binary tree

Reverse a Linked List

Reverse a singly linked list in-place

Reverse Nodes in k-Group

Reverse every k consecutive nodes in a linked list

Swap Nodes in Pairs

Swap every two adjacent nodes in a linked list

Symmetric Tree

Check if a binary tree is symmetric around its center.