DSA Practice Questions (For Interview Prep)
Array Variations
- Longest Consecutive Sequence – find the length of the longest sequence of consecutive
numbers.
- Subarray with Product < K – count how many subarrays have product less than a given number.
- Maximum Circular Subarray Sum – handle wrap-around subarrays.
- Next Permutation – rearrange numbers to the lexicographically next permutation.
- Container With Most Water – two-pointer problem for max area between vertical lines.
Binary Search Twists
- Find Minimum in Rotated Sorted Array (with duplicates allowed).
- Search in Rotated Sorted Array II (duplicates included).
- Median of Two Sorted Arrays – very popular interview question.
- Allocate Minimum Pages / Painter’s Partition Problem (binary search on answer).
Hashing / Frequency
- Longest Subarray with Equal 0s and 1s.
- Subarray Sum Equals K (track prefix sum with hashmap).
- Longest Substring Without Repeating Characters.
- Group Anagrams from a list of strings.
- Top K Frequent Elements.
Two-pointer / Sliding Window
- Minimum Window Substring (classic hard one).
- Longest Repeating Character Replacement.
- Find All Anagrams in a String.
- Max Consecutive Ones III – flip at most k zeroes.
Stacks & Intervals
- Next Greater Element (basic + circular array version).
- Largest Rectangle in Histogram.
- Trapping Rain Water.
- Insert Interval (variation of merge intervals).
String Problems
- Longest Palindromic Substring (expand around center).
- Palindrome Partitioning (backtracking).
- Word Break Problem (DP).
- Count and Say Sequence.
Bit Manipulation
- Single Number (every element appears twice except one).
- Single Number II (every element appears thrice except one).
- Power of Two / Power of Four checks.
- Count Set Bits in a Number.