Recursion

Double a Number Represented as a Linked List

LeetCode problem #2816

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.

Combination Sum

Given an array of distinct integers and a target, return all unique combinations where the chosen numbers sum to target (elements may be reused)

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

LC 25 Reverse Nodes in k-Group (Linked List) | O(1)

Reverse linked list in k groups (Hard): in-place pointer reversal with dummy node. Optimal O(n) time, O(1) space—step-by-step solution.

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

N-Queens

Place n queens on an n x n chessboard such that no two queens attack each other, and return all distinct solutions

Path Sum

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

Permutations

Given an array of distinct integers, return all the possible permutations in any order

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 and return the new head.

Reverse Linked List (LC 206) — 3-Pointer In-Place

Learn how to reverse a singly linked list (LeetCode 206) with the optimal 3-pointer iterative method: O(n) time, O(1) space. Practice now.

Subsets

Given an integer array of unique elements, return all possible subsets (the power set)

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.

Word Search

Given an m x n grid of characters and a string word, return true if the word exists in the grid by traversing adjacent cells without reusing any cell