Prefix Sum DSA Problems

204 prefix sum problems for coding interviews and campus placements, with hints and company tags. Below are the first 100 of 204: 18 easy, 30 medium and 52 hard. Practise them free on InternHack and track what you have solved.

Prefix Sum problems, easiest first

  1. Ant on the Boundary (Easy)
  2. Check if All the Integers in a Range Are Covered (Easy)
  3. Count Partitions with Even Sum Difference (Easy)
  4. Find Pivot Index (Easy)
  5. Find the Highest Altitude (Easy)
  6. Find the Middle Index in Array (Easy)
  7. Find the Pivot Integer (Easy)
  8. Left and Right Sum Differences (Easy)
  9. Longest Subsequence With Limited Sum (Easy)
  10. Make Array Elements Equal to Zero (Easy)
  11. Maximum Population Year (Easy)
  12. Maximum Score After Splitting a String (Easy)
  13. Minimum Positive Sum Subarray (Easy)
  14. Minimum Value to Get Positive Step by Step Sum (Easy)
  15. Points That Intersect With Cars (Easy)
  16. Range Sum Query - Immutable (Easy)
  17. Running Sum of 1d Array (Easy)
  18. Sum of All Odd Length Subarrays (Easy)
  19. Apply Operations to Make All Array Elements Equal to Zero (Medium)
  20. Average Height of Buildings in Each Segment (Medium)
  21. Best Time to Buy and Sell Stock using Strategy (Medium)
  22. Binary Subarrays With Sum (Medium)
  23. Bitwise OR of All Subsequence Sums (Medium)
  24. Brightest Position on Street (Medium)
  25. Can Make Palindrome from Substring (Medium)
  26. Can You Eat Your Favorite Candy on Your Favorite Day? (Medium)
  27. Car Pooling (Medium)
  28. Change Minimum Characters to Satisfy One of Three Conditions (Medium)
  29. Concatenate Non-Zero Digits and Multiply by Sum II (Medium)
  30. Construct Product Matrix (Medium)
  31. Contiguous Array (Medium)
  32. Continuous Subarray Sum (Medium)
  33. Corporate Flight Bookings (Medium)
  34. Count Beautiful Substrings I (Medium)
  35. Count Number of Nice Subarrays (Medium)
  36. Count of Interesting Subarrays (Medium)
  37. Count Partitions With Max-Min Difference at Most K (Medium)
  38. Count Positions on Street With Required Brightness (Medium)
  39. Count Submatrices With Equal Frequency of X and Y (Medium)
  40. Count Submatrices with Top-Left Element and Sum Less Than k (Medium)
  41. Count the Hidden Sequences (Medium)
  42. Count the Number of Houses at a Certain Distance I (Medium)
  43. Count Triplets That Can Form Two Arrays of Equal XOR (Medium)
  44. Count Vowel Strings in Ranges (Medium)
  45. Describe the Painting (Medium)
  46. Design Exam Scores Tracker (Medium)
  47. Divide Intervals Into Minimum Number of Groups (Medium)
  48. Find All Good Indices (Medium)
  49. Apply Operations to Maximize Frequency Score (Hard)
  50. Build Array Where You Can Find The Maximum Exactly K Comparisons (Hard)
  51. Count Beautiful Substrings II (Hard)
  52. Count Increasing Quadruplets (Hard)
  53. Count Routes to Climb a Rectangular Grid (Hard)
  54. Count Subarrays With Median K (Hard)
  55. Count Subarrays With Score Less Than K (Hard)
  56. Count the Number of Houses at a Certain Distance II (Hard)
  57. Delivering Boxes from Storage to Ports (Hard)
  58. Find All Possible Stable Binary Arrays II (Hard)
  59. Find the Count of Monotonic Pairs I (Hard)
  60. Find the Count of Monotonic Pairs II (Hard)
  61. Find the Original Typed String II (Hard)
  62. Longest Balanced Subarray II (Hard)
  63. Longest Special Path II (Hard)
  64. Max Sum of Rectangle No Larger Than K (Hard)
  65. Maximize Subarrays After Removing One Conflicting Pair (Hard)
  66. Maximize the Beauty of the Garden (Hard)
  67. Maximize the Minimum Powered City (Hard)
  68. Maximum Average Subarray II (Hard)
  69. Maximum Difference Between Even and Odd Frequency II (Hard)
  70. Maximum Frequency of an Element After Performing Operations II (Hard)
  71. Maximum Fruits Harvested After at Most K Steps (Hard)
  72. Maximum Number of Robots Within Budget (Hard)
  73. Maximum Number of Ways to Partition an Array (Hard)
  74. Maximum Score From Grid Operations (Hard)
  75. Maximum Segment Sum After Removals (Hard)
  76. Maximum Strength of K Disjoint Subarrays (Hard)
  77. Maximum Sum of 3 Non-Overlapping Subarrays (Hard)
  78. Maximum Total Beauty of the Gardens (Hard)
  79. Maximum Value of K Coins From Piles (Hard)
  80. Merge Operations for Minimum Travel Time (Hard)
  81. Minimum Adjacent Swaps for K Consecutive Ones (Hard)
  82. Minimum Cost to Make Array Equal (Hard)
  83. Minimum Cost to Merge Stones (Hard)
  84. Minimum Moves to Pick K Ones (Hard)
  85. Minimum Number of K Consecutive Bit Flips (Hard)
  86. Minimum Space Wasted From Packaging (Hard)
  87. Minimum White Tiles After Covering With Carpets (Hard)
  88. My Calendar III (Hard)
  89. Number of Beautiful Partitions (Hard)
  90. Number of Flowers in Full Bloom (Hard)
  91. Number of Submatrices That Sum to Target (Hard)
  92. Number of Ways of Cutting a Pizza (Hard)
  93. Shortest Subarray with Sum at Least K (Hard)
  94. Sorted GCD Pair Queries (Hard)
  95. Split Array Largest Sum (Hard)
  96. Split Array with Equal Sum (Hard)
  97. Stamping the Grid (Hard)
  98. Stone Game VIII (Hard)
  99. Sum of Total Strength of Wizards (Hard)
  100. Threshold Majority Queries (Hard)

Companies that ask prefix sum problems

Before your interview

Most resumes are filtered by software before a recruiter reads them. Check your resume ATS score free, no signup needed.

Other DSA topics