Top 100 Array Problems
Basics & Fundamentals
1. Find the maximum/minimum element
2. Reverse the array
3. Search an element (Linear Search / Binary Search)
4. Find the sum of elements
5. Check if array is sorted
6. Rotate array by one
7. Left rotate an array by d places
8. Right rotate an array by d places
9. Find duplicate elements
10. Remove duplicates from sorted array
Intermediate Level
1. Kadane's Algorithm - Maximum Subarray Sum
2. Merge two sorted arrays
3. Move all zeros to end
4. Sort 0s, 1s, 2s (Dutch National Flag)
5. Union of two arrays
6. Intersection of two arrays
7. Count frequency of elements
8. Find missing number from 1 to n
9. Find the number that appears once, others twice
10. Second largest/smallest element
Subarrays & Sliding Window
1. Maximum sum subarray of size k
2. Count subarrays with given sum
3. Longest subarray with sum k
4. Longest subarray with equal 0s and 1s
5. Subarray with given XOR
6. Smallest subarray with sum >= k
7. Count number of subarrays with product less than k
8. Count number of nice subarrays
9. Count all subarrays with equal number of 0s and 1s
10. Maximum average subarray
Sorting & Searching
1. QuickSort, MergeSort implementations
2. Kth smallest/largest element
3. Find peak element
4. Search in rotated sorted array
5. Count inversions in array
6. Median of two sorted arrays
7. Find majority element (>n/2 times)
8. Find elements appearing > n/3 times
9. Ceiling and floor in sorted array
10. Minimum swaps to sort
Prefix, Suffix & Difference Arrays
1. Prefix sum array problems
2. Range sum queries (Prefix)
3. Difference array for range updates
4. Construct array from difference array
5. Max frequency of element after operations
6. Range addition using difference array
7. Number of ways to reach a sum using prefix sum
8. Prefix XOR problems
9. Max subarray XOR
10. Suffix sum problems
Binary Search & Optimization
1. Minimum in rotated sorted array
2. Find k closest elements
3. Minimum number in mountain array
4. Allocate minimum number of pages
5. Painters partition problem
6. Capacity to ship packages in D days
7. Aggressive cows (maximize minimum distance)
8. Koko eating bananas (minimize speed)
9. Binary search on answer concept
10. Peak index in a mountain array
Matrix-based Array Problems
1. Rotate matrix by 90 degrees
2. Search in 2D matrix
3. Set matrix zeroes
4. Spiral traversal of matrix
5. Diagonal traversal
6. Transpose matrix
7. Word search in matrix
8. Longest increasing path in matrix
9. Count islands (DFS)
10. Max area of island
Advanced & Hard
1. Maximum product subarray
2. Maximum sum circular subarray
3. Merge overlapping intervals
4. Insert interval
5. Non-overlapping intervals
6. Minimum platforms required
7. Trapping rainwater
8. Container with most water
9. Largest rectangle in histogram
10. Maximum size submatrix with all 1s
Miscellaneous
1. Next greater element
2. Stock buy & sell (1 transaction)
3. Stock buy & sell (multiple transactions)
4. Stock buy & sell (2 transactions)
5. Count pairs with given sum
6. Find triplets that sum to zero
7. Find quadruplets that sum to target
8. Product of array except self
9. Rearrange array in alternating positive and negative
10. Longest consecutive sequence
Special Problems
1. Subarrays with equal number of even and odd
2. Count of smaller elements after self
3. Maximum of minimum for every window size
4. Sliding window maximum
5. Minimum number of jumps to reach end
6. Detect cycle in array using Floyd's cycle
7. Find repeating and missing number
8. Rearrange array as i -> arr[arr[i]]
9. Build array from permutation
10. Find longest mountain