The sliding window technique is used to solve problems that involve subarrays or substrings. It involves moving a window of a fixed size or a dynamically sized window across the array or string to find a solution.
- Maximum Sum Subarray of Size K (Easy)
- Longest Substring Without Repeating Characters (Medium)
- Permutation in String (Medium)
- Longest Substring with At Most K Distinct Characters (Hard)
- Minimum Window Substring (Hard)
- Smallest Subarray with a Given Sum (Easy)
- Fruit Into Baskets (Medium)
- Sliding Window Maximum (Hard)
- Subarrays with K Different Integers (Hard)
- Replace the Substring for Balanced String (Medium)
The two-pointer technique involves using two pointers to traverse the array or list. It's particularly useful for problems that involve pairs or require searching for two elements in a sorted array.
- Two Sum II - Input Array is Sorted (Easy)
- Remove Duplicates from Sorted Array (Easy)
- Container With Most Water (Medium)
- 3Sum (Medium)
- Four Sum (Medium)
- Move Zeroes (Easy)
- Linked List Cycle II (Medium)
- Palindrome Linked List (Easy)
- Remove Nth Node From End of List (Medium)
- Trapping Rain Water (Hard)
Fast and slow pointers (also known as the tortoise and hare algorithm) are used to detect cycles in data structures like linked lists or to find the middle element.
- Linked List Cycle (Easy)
- Middle of the Linked List (Easy)
- Find the Duplicate Number (Medium)
- Happy Number (Easy)
- Palindrome Linked List (Easy)
- Reorder List (Medium)
- Intersection of Two Linked Lists (Easy)
- Cycle Detection in Directed Graph (Hard)
- Cycle Detection in Undirected Graph (Medium)
- Split Linked List in Parts (Medium)
Merge intervals technique is used to solve problems that involve overlapping intervals. The main idea is to sort the intervals and then merge overlapping intervals.
- Merge Intervals (Medium)
- Insert Interval (Medium)
- Interval List Intersections (Medium)
- Meeting Rooms (Easy)
- Meeting Rooms II (Medium)
- Minimum Interval to Include Each Query (Hard)
- Employee Free Time (Hard)
- Non-overlapping Intervals (Medium)
- Partition Labels (Medium)
- Car Pooling (Medium)
Cyclic sort is useful for problems where numbers are within a specific range and you need to sort them with minimal space and time complexity.
- Missing Number (Easy)
- Find All Numbers Disappeared in an Array (Easy)
- Find the Duplicate Number (Medium)
- Find All Duplicates in an Array (Medium)
- Set Mismatch (Easy)
- First Missing Positive (Hard)
- Kth Missing Positive Number (Easy)
- Find the Missing Number in a Sorted Array (Easy)
- Find the Error Number (Easy)
- Check Array Formation Through Concatenation (Easy)
In-place reversal involves reversing portions of a linked list without using extra space.
- Reverse Linked List (Easy)
- Reverse Linked List II (Medium)
- Reverse Nodes in k-Group (Hard)
- Swap Nodes in Pairs (Medium)
- Rotate List (Medium)
- Reverse Substrings Between Each Pair of Parentheses (Medium)
- Reverse Even Length Groups (Medium)
- Palindrome Linked List (Easy)
- Split Linked List in Parts (Medium)
- Flatten a Multilevel Doubly Linked List (Medium)
Tree traversal techniques include inorder, preorder, and postorder traversals, which are used to visit all nodes in a tree in a specific order.
- Binary Tree Inorder Traversal (Easy)
- Binary Tree Preorder Traversal (Easy)
- Binary Tree Postorder Traversal (Easy)
- Binary Tree Level Order Traversal (Medium)
- Binary Tree Zigzag Level Order Traversal (Medium)
- Vertical Order Traversal of a Binary Tree (Hard)
- Serialize and Deserialize Binary Tree (Hard)
- Construct Binary Tree from Preorder and Inorder Traversal (Medium)
- Binary Tree Maximum Path Sum (Hard)
- Lowest Common Ancestor of a Binary Tree (Medium)
Graph traversal techniques such as Breadth-First Search (BFS) and Depth-First Search (DFS) are used to explore nodes and edges in a graph.
- Number of Islands (Medium)
- Clone Graph (Medium)
- Graph Valid Tree (Medium)
- Word Ladder (Hard)
- Course Schedule (Medium)
- Course Schedule II (Medium)
- Pacific Atlantic Water Flow (Medium)
- All Paths From Source to Target (Medium)
- Critical Connections in a Network (Hard)
- Find Eventual Safe States (Medium)
Binary search is a divide-and-conquer algorithm used to find elements in a sorted array or to determine the position of an element.
- Binary Search (Easy)
- Search Insert Position (Easy)
- Find Minimum in Rotated Sorted Array (Medium)
- Find Peak Element (Medium)
- Search in Rotated Sorted Array (Medium)
- Time Based Key-Value Store (Medium)
- Median of Two Sorted Arrays (Hard)
- Koko Eating Bananas (Medium)
- Capacity To Ship Packages Within D Days (Medium)
- Find K Closest Elements (Medium)
Greedy algorithms make locally optimal choices at each step with the hope of finding a global optimum.
- Activity Selection (N/A)
- Fractional Knapsack (N/A)
- Job Sequencing Problem (N/A)
- Candy (Hard)
- Jump Game II (Medium)
- Assign Cookies (Easy)
- Gas Station (Medium)
- Minimum Number of Arrows to Burst Balloons (Medium)
- Queue Reconstruction by Height (Medium)
- Reorganize String (Medium)
Dynamic Programming involves breaking down problems into overlapping subproblems and solving each subproblem only once.
- Fibonacci Number (Easy)
- Climbing Stairs (Easy)
- House Robber (Medium)
- House Robber II (Medium)
- Longest Increasing Subsequence (Medium)
- Coin Change (Medium)
- Partition Equal Subset Sum (Medium)
- Unique Paths (Medium)
- Longest Common Subsequence (Medium)
- Edit Distance (Hard)
Backtracking involves exploring all potential solutions and backtracking once an invalid solution is found to try another path.
- N-Queens (Hard)
- Subsets (Medium)
- Permutations (Medium)
- Combination Sum (Medium)
- Word Search (Medium)
- Palindrome Partitioning (Medium)
- Letter Combinations of a Phone Number (Medium)
- Sudoku Solver (Hard)
- Generate Parentheses (Medium)
- Combination Sum II (Medium)
Bit manipulation involves using bitwise operations to solve problems efficiently by manipulating individual bits of numbers.
- Single Number (Easy)
- Number of 1 Bits (Easy)
- Counting Bits (Easy)
- Missing Number (Easy)
- Power of Two (Easy)
- Bitwise AND of Numbers Range (Medium)
- Binary Watch (Easy)
- Reverse Bits (Easy)
- Maximum XOR of Two Numbers in an Array (Medium)
- Sum of Two Integers (Medium)
These problems leverage mathematical properties, formulas, and techniques to find solutions efficiently.
- Count Primes (Easy)
- Valid Perfect Square (Easy)
- Roman to Integer (Easy)
- Integer to Roman (Medium)
- Pascal's Triangle (Easy)
- Excel Sheet Column Number (Easy)
- Power of Three (Easy)
- Super Pow (Medium)
- Pow(x, n) (Medium)
- Kth Largest Element in an Array (Medium)
Topological sort is used to order vertices in a Directed Acyclic Graph (DAG).
- Course Schedule (Medium)
- Course Schedule II (Medium)
- Alien Dictionary (Hard)
- Minimum Height Trees (Medium)
- Longest Increasing Path in a Matrix (Hard)
- Sequence Reconstruction (Medium)
- Parallel Courses (Medium)
- Reconstruct Original Digits from English (Medium)
- Longest Consecutive Sequence (Medium)
- Checking Existence of Edge Length Limited Paths (Hard)
Union-Find is a data structure that keeps track of a set of elements partitioned into disjoint (non-overlapping) subsets. It supports union and find operations.
- Number of Connected Components in an Undirected Graph (Medium)
- Redundant Connection (Medium)
- Graph Valid Tree (Medium)
- Accounts Merge (Medium)
- Most Stones Removed with Same Row or Column (Medium)
- Smallest String With Swaps (Medium)
- Find Redundant Connection II (Hard)
- Swim in Rising Water (Hard)
- Largest Component Size by Common Factor (Hard)
- Earliest Moment When Everyone Become Friends (Medium)
Heaps are a specialized tree-based data structure that satisfy the heap property. They are useful for problems that require frequent access to the smallest or largest elements.
- Kth Largest Element in a Stream (Easy)
- Top K Frequent Elements (Medium)
- Find Median from Data Stream (Hard)
- Merge k Sorted Lists (Hard)
- Task Scheduler (Medium)
- Sort Characters By Frequency (Medium)
- Reorganize String (Medium)
- Minimum Cost to Connect Sticks (Medium)
- Meeting Rooms II (Medium)
- Kth Smallest Element in a Sorted Matrix (Medium)