Minimum Cost Tree From Leaf Values
LeetCode problem #1130
Double a Number Represented as a Linked List
LeetCode problem #2816
Gas Station
LeetCode problem #134
Making A Large Island
LeetCode problem #827
Closest Dessert Cost
LeetCode problem #1774
Sum of Mutated Array Closest to Target
LeetCode problem #1300
0/1 Knapsack
Find maximum value that can be obtained with given weight capacity
Add Two Numbers
Add two numbers represented as linked lists where digits are stored in reverse order
Binary Search
Given a sorted array of integers and a target value, return the index of the target if found, or -1 if not present.
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.
Breadth-First Search (BFS) Algorithm: Queue + O(V+E)
Learn BFS traversal with a FIFO queue + visited set. Includes BFS pseudocode, example, and O(V+E) complexity—practice for FAANG interviews.
Buy and Sell Stock (Maximum Profit)
Find the maximum profit from buying and selling stock with at most one transaction
Candy
Distribute the minimum number of candies to children in a line such that each child gets at least one and children with higher ratings get more than their neighbors
Celebrity Problem
Find the celebrity in a party of n people using the minimum number of questions.
Check if String is Palindrome
Determine if a string reads the same forwards and backwards, ignoring case and non-alphanumeric characters.
Check if String is Rotation of Another
Determine if one string is a rotation of another string by checking if it can be formed by rotating the characters.
Circular Linked List Detection
Detect if a linked list has a cycle and find the starting point of the cycle
Coin Change (Minimum Coins)
Find the minimum number of coins needed to make a given amount
Coin Change II LC 518: DP Count Ways (Unbounded)
Medium DP/unbounded knapsack: dp[x]+=dp[x-c] counts coin change ways (no permutations). O(n·amount) time, O(amount) space. Practice now.
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.
Copy List with Random Pointer
Create a deep copy of a linked list where each node has a random pointer
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.
Daily Temperatures
Find the number of days until a warmer temperature for each day.
Decode String
Decode a string encoded with the format k[encoded_string].
Design Circular Queue
Design a circular queue with fixed size that supports enqueue, dequeue, front, rear, isEmpty, and isFull operations.
Detect Cycle in Directed Graph
Determine if a directed graph contains a cycle
Detect Cycle in Linked List
Detect if a linked list has a cycle using Floyd's cycle detection algorithm
Detect Cycle in Undirected Graph (DFS/BFS, Union-Find)
Learn graph cycle detection in an undirected graph using DFS/BFS parent tracking or Union-Find (DSU). O(V+E). Step-by-step—practice now.
Diameter of Binary Tree
Find the diameter (longest path) of a binary tree.
Edit Distance
Find minimum operations to convert one string to another
Edit Distance (Levenshtein Distance)
Find the minimum number of operations (insert, delete, replace) required to transform one string into another.
Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Expression Evaluation
Evaluate mathematical expressions with proper operator precedence and parentheses.
Fibonacci Numbers
Calculate the nth Fibonacci number using dynamic programming
Find Majority Element (Boyer-Moore Algorithm)
Find the majority element that appears more than n/2 times using Boyer-Moore majority vote algorithm
Find Middle of Linked List
Find the middle node of a linked list using the two-pointer technique
Find Missing Number (1 to n)
Find the missing number in an array containing n distinct numbers taken from 1, 2, 3, ..., n+1
First Unique Character in String
Find the first non-repeating character in a string and return its index.
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.
Group Anagrams
Given an array of strings, group the anagrams together.
Group Anagrams
Group strings that are anagrams of each other together.
House Robber
Find maximum amount that can be robbed without robbing adjacent houses
Implement Queue
Implement a queue using arrays or linked lists with O(1) time complexity for all operations.
Implement Queue using Stacks
Implement a queue using two stacks with O(1) amortized time complexity for all operations.
Implement Stack using Queues
Implement a stack using two queues with O(1) amortized time complexity for all operations.
Implement strStr (Find Substring)
Find the first occurrence of a substring in a string, similar to strstr() function.
Intersection of Two Arrays
Find the intersection of two arrays and return the result as an array.
Intersection of Two Linked Lists
Find the intersection node of two linked lists
Invert Binary Tree
Invert (mirror) a binary tree by swapping left and right children
Jump Game
Determine if you can reach the last index of an array where each element represents the maximum jump length from that position
Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
LC 237 Delete Node in Linked List (O(1) Trick)
Learn the optimal O(1) in-place “copy-and-skip” to delete a node in a linked list without head/prev. Easy interview prep—see examples.
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.
Level Order Traversal
Traverse a binary tree level by level from left to right.
Longest Common Prefix
Find the longest common prefix string amongst an array of strings.
Longest Common Subsequence
Find the length of the longest common subsequence between two strings
Longest Consecutive Sequence
Find the length of the longest consecutive elements sequence in an unsorted array.
Longest Increasing Subsequence
Find the length of the longest increasing subsequence in an array
Longest Repeated Substring
Find the longest substring that appears at least twice in a string
Lowest Common Ancestor
Find the lowest common ancestor of two nodes in a binary tree.
LRU Cache
Design a data structure that follows Least Recently Used (LRU) eviction with O(1) get and put operations.
Max Stack
Design a stack that supports push, pop, top, peekMax, and popMax operations
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.
Maximum Subarray Sum (Kadane's Algorithm)
Find the contiguous subarray with maximum sum using Kadane's algorithm
Merge Intervals
Given an array of intervals where intervals[i] = [start_i, end_i], merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input.
Merge k Sorted Linked Lists
Merge k sorted linked lists into one sorted linked list
Merge Two Sorted Lists
Merge two sorted linked lists into one sorted linked list
Minimum Insertions to Balance Parentheses
Find minimum insertions needed to balance parentheses string
Minimum Swaps to Sort Array
Find the minimum number of swaps required to sort an array.
Missing Number
Find the missing number in an array containing n distinct numbers taken from 0, 1, 2, ..., n.
N-Queens
Place n queens on an n x n chessboard such that no two queens attack each other, and return all distinct solutions
Next Greater Element
Find the next greater element for each element in an array.
Number of Islands
Count the number of islands in a 2D grid
Palindrome Linked List
Check if a linked list is a palindrome using O(1) extra space
Partition List
Partition a linked list around a value x such that all nodes less than x come before nodes greater than or equal to x
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)
Power of Two
Check if a given integer is a power of two.
Print All Root-to-Leaf Paths
Print all root-to-leaf paths in a binary tree
Product of Array Except Self
Return an array where each element is the product of all elements except the element at that index.
Regular Expression Matching
Implement regular expression matching with '.' and '*'
Remove Duplicates from Sorted List
Remove all duplicate values from a sorted linked list
Remove K Digits
Remove k digits from a number to make it as small as possible
Remove Nth Node From End of List
Remove the nth node from the end of a linked list in one pass
Reorder List
Reorder a linked list by interleaving nodes from the beginning and end
Reverse Bits
Reverse the bits of a given 32-bit unsigned integer.
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.
Reverse String
Reverse a string in-place using O(1) extra memory.
Rotate Linked List
Rotate a linked list to the right by k places
Search in Rotated Sorted Array
Given a rotated sorted array and a target value, return the index of the target if found in O(log n) time, or -1 if not present.
Serialization Formats Comparison
JSON vs Protocol Buffers vs Avro vs Thrift - choosing the right format
Single Number
Find the single number that appears once in an array where every other number appears twice.
Sliding Window Maximum
Find the maximum element in each sliding window of size k.
Sort Linked List
Sort a linked list in O(n log n) time using constant extra space
String Compression
Compress a string by replacing consecutive characters with character and count.
Strongly Connected Components
Find all strongly connected components in a directed graph
Subarray with Given Sum
Find a subarray with a given sum in an array of positive integers.
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.
Task Scheduler
Find the minimum number of intervals the CPU will take to finish all given tasks with a cooldown period between identical tasks
Three Sum (Triplets that Sum to Zero)
Find all unique triplets in the array which gives the sum of zero
Top K Frequent Elements
Given an integer array and k, return the k most frequent elements.
Topological Sort
Find a linear ordering of vertices in a directed acyclic graph
Two Sum
Find two numbers in an array that add up to a target value.
Two Sum
Given an array of integers and a target, return indices of two numbers that add up to the target.
Unique Paths in Grid
Count unique paths from top-left to bottom-right in a grid
Valid Parentheses
Check if a string containing only parentheses is valid.
Word Break
Determine if a string can be segmented into space-separated words from a dictionary.
Word Break II (LC 140) — DFS + Memo DP (Hard)
Solve LeetCode 140 Word Break II with DFS + memoization DP. Output-sensitive (≈O(n²)+answers). Step-by-step for interviews—practice now.
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