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
Alien Dictionary
Given a sorted dictionary of alien language, find the order of characters in the alien alphabet
All Paths From Source to Target
Find all possible paths from source node to target node in a directed acyclic graph (DAG)
Articulation Points (Cut Vertices)
Find all articulation points in an undirected graph - vertices whose removal increases the number of connected components
Bellman-Ford Algorithm
Find shortest paths from a source vertex to all other vertices in a weighted graph, capable of handling negative edge weights
BFS Shortest Path in Unweighted Graph
Find shortest path between two vertices in an unweighted graph using BFS traversal
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)
Implement breadth-first search traversal of a graph
Buy and Sell Stock (Maximum Profit)
Find the maximum profit from buying and selling stock with at most one transaction
Celebrity Problem
Find the celebrity in a party of n people using the minimum number of questions.
Check if Array is Sorted
Determine if an array is sorted in ascending, descending, or not sorted at all
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
Climbing Stairs
Count the number of distinct ways to reach the top of n stairs
Clone Graph
Create a deep copy of an undirected graph represented with adjacency lists
Coin Change (Minimum Coins)
Find the minimum number of coins needed to make a given amount
Coin Change II (Number of Ways)
Count the number of ways to make a given amount using coins
Connect Ropes with Minimum Cost
Connect ropes with minimum cost using greedy approach with heap
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.
Course Schedule
Determine if you can finish all courses given prerequisite relationships using topological sorting
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].
Delete Node in a Linked List
Delete a node from a linked list when you only have access to that node
Depth-First Search (DFS)
Implement depth-first search traversal for graphs
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
Determine if an undirected graph contains a cycle
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.
Exponential Backoff
Retry strategy that progressively increases delay between retry attempts to handle transient failures and prevent system overload
Expression Evaluation
Evaluate mathematical expressions with proper operator precedence and parentheses.
Fibonacci Numbers
Calculate the nth Fibonacci number using dynamic programming
Find Bridges in a Graph
Find all bridges (critical edges) in an undirected graph using Tarjan's algorithm
Find Duplicate Number
Find the duplicate number in an array containing n+1 integers where each integer is between 1 and n (inclusive)
Find K Largest Elements
Find the k largest elements from an unsorted array
Find K Smallest Elements
Find the k smallest elements from an unsorted array
Find Majority Element (Boyer-Moore Algorithm)
Find the majority element that appears more than n/2 times using Boyer-Moore majority vote algorithm
Find Median from Data Stream
Design data structure to find median from continuous stream of integers
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
Find the Maximum Element in an Array
Find and return the largest element in an array of integers
Find the Second Largest Element in an Array
Find and return the second largest element in an array of integers
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
Floyd-Warshall Algorithm - All Pairs Shortest Path
Find shortest paths between all pairs of vertices in a weighted graph using dynamic programming
Furthest Building You Can Reach
Find furthest building reachable using optimal allocation of bricks and ladders
Generate Permutations
Generate all possible permutations of a given string.
Group Anagrams
Group strings that are anagrams of each other together.
Horizontal Scaling
Scaling strategy that increases system capacity by adding more machines or instances rather than upgrading existing hardware
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
Design and implement a stack data structure with push, pop, top, and empty 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
Inverted Indexes
Full-text search and information retrieval using inverted indexes
Is Graph Bipartite
Check if a graph can be colored with exactly two colors such that no two adjacent nodes have the same color
Kth Largest Element in Array
Find the kth largest element in an unsorted array
Kth Smallest Element in Sorted Matrix
Find kth smallest element in row and column sorted matrix using heap
Largest Rectangle in Histogram
Find the largest rectangle that can be formed in a histogram
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 Palindromic Substring
Find the longest palindromic substring in a given string
Longest Repeated Substring
Find the longest substring that appears at least twice in a string
Longest Substring Without Repeating Characters
Find the length of the longest substring without repeating characters
Lowest Common Ancestor
Find the lowest common ancestor of two nodes in a binary tree.
Max Stack
Design a stack that supports push, pop, top, peekMax, and popMax operations
Maximize Sum After K Negations
Maximize array sum by flipping signs of k elements using greedy heap approach
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
Meeting Rooms II
Find minimum number of meeting rooms required using heap
Merge K Sorted Arrays
Merge k sorted arrays into one sorted array using heap
Merge k Sorted Linked Lists
Merge k sorted linked lists into one sorted linked list
Merge Two Sorted Arrays
Merge two sorted arrays into a single sorted array in-place
Merge Two Sorted Lists
Merge two sorted linked lists into one sorted linked list
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time
Minimum Insertions to Balance Parentheses
Find minimum insertions needed to balance parentheses string
Minimum Number of Refueling Stops
Find minimum refueling stops to reach target using greedy max-heap approach
Minimum Spanning Tree
Find the minimum spanning tree of a weighted undirected graph using Kruskal's and Prim's algorithms
Minimum Swaps to Sort Array
Find the minimum number of swaps required to sort an array.
Minimum Window Substring
Find the minimum window substring that contains all characters of another string
Missing Number
Find the missing number in an array containing n distinct numbers taken from 0, 1, 2, ..., n.
Move All Zeros to the End
Move all zeros in an array to the end while maintaining the relative order of non-zero elements
Network Delay Time (Dijkstra's Algorithm)
Find the time it takes for a signal to reach all nodes in a network using shortest path algorithms
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
Optimistic Locking
Concurrency control mechanism that assumes conflicts are rare and handles them when they occur, using version numbers or timestamps to detect concurrent modifications
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.
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.
Reduce Array Size to Half
Find minimum removals to reduce array size by half using greedy heap approach
Regular Expression Matching
Implement regular expression matching with '.' and '*'
Regular Expression Matching
Implement regular expression matching with support for '.' 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
Reorganize String
Reorganize string so no two adjacent characters are the same
Reverse a Linked List
Reverse a singly linked list in-place
Reverse an Array
Reverse the order of elements in an array in-place and return the modified array
Reverse Bits
Reverse the bits of a given 32-bit unsigned integer.
Reverse Nodes in k-Group
Reverse every k consecutive nodes in a linked list
Reverse String
Reverse a string in-place using O(1) extra memory.
Rotate Array by K Steps
Rotate an array to the right by k steps where k is non-negative
Rotate Linked List
Rotate a linked list to the right by k places
Rotten Oranges Problem
Find the minimum time for all oranges to rot using BFS
Serialize and Deserialize Binary Tree
Serialize a binary tree to a string and deserialize it back to the original tree
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
Sliding Window Maximum
Find the maximum element in each sliding window of size k.
Sliding Window Median
Find median in each sliding window using two heaps
Smallest Substring with All Characters
Find the smallest substring that contains all characters of a given pattern
Sort Characters by Frequency
Sort characters in string by frequency using heap or bucket sort
Sort Linked List
Sort a linked list in O(n log n) time using constant extra space
Stock Span Problem
Calculate the span of stock prices for each day
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.
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
Schedule tasks with cooling period using greedy approach with heap
Three Sum (Triplets that Sum to Zero)
Find all unique triplets in the array which gives the sum of zero
Top K Frequent Elements
Find the k most frequent elements in an array
Topological Sort
Find a linear ordering of vertices in a directed acyclic graph
Trapping Rain Water
Calculate how much rainwater can be trapped between bars of different heights
Two Sum
Find two numbers in an array that add up to a target value.
Ugly Numbers (Heap-based)
Find the nth ugly number using heap-based approach
Unique Paths in Grid
Count unique paths from top-left to bottom-right in a grid
Valid Anagram
Determine if two strings are anagrams of each other
Valid Parentheses
Determine if the input string has valid brackets that are properly opened and closed
Valid Parentheses
Check if a string containing only parentheses is valid.
Vertical Order Traversal of Binary Tree
Traverse a binary tree vertically and return nodes by columns
Word Break
Determine if a string can be segmented into space-separated words from a dictionary.
Word Break II
Return all possible ways to break a string into dictionary words
Word Ladder
Find the shortest transformation sequence from beginWord to endWord using single character changes
Zigzag Level Order Traversal
Traverse a binary tree level by level in zigzag order