Segment Tree DSA Problems

60 segment tree problems for coding interviews and campus placements, with hints and company tags. Below are all 60: 1 easy, 15 medium and 44 hard. Practise them free on InternHack and track what you have solved.

Segment Tree problems, easiest first

  1. Fruits Into Baskets II (Easy)
  2. Count Number of Teams (Medium)
  3. Count Subarrays With More Ones Than Zeros (Medium)
  4. Fruits Into Baskets III (Medium)
  5. Longest Balanced Subarray I (Medium)
  6. Longest Uploaded Prefix (Medium)
  7. Maximum Area Rectangle With Point Constraints I (Medium)
  8. Maximum Profitable Triplets With Increasing Prices I (Medium)
  9. Minimum Number of Valid Strings to Form Target I (Medium)
  10. My Calendar I (Medium)
  11. My Calendar II (Medium)
  12. Number of Longest Increasing Subsequence (Medium)
  13. Queue Reconstruction by Height (Medium)
  14. Range Frequency Queries (Medium)
  15. Range Sum Query - Mutable (Medium)
  16. Range Sum Query 2D - Mutable (Medium)
  17. Amount of New Area Painted Each Day (Hard)
  18. Block Placement Queries (Hard)
  19. Booking Concert Tickets in Groups (Hard)
  20. Count Good Triplets in an Array (Hard)
  21. Count Integers in Intervals (Hard)
  22. Count Non-Decreasing Subarrays After K Operations (Hard)
  23. Count of Range Sum (Hard)
  24. Count of Smaller Numbers After Self (Hard)
  25. Count the Number of K-Big Indices (Hard)
  26. Create Sorted Array through Instructions (Hard)
  27. Delivering Boxes from Storage to Ports (Hard)
  28. Distribute Elements Into Two Arrays II (Hard)
  29. Falling Squares (Hard)
  30. Fancy Sequence (Hard)
  31. Find a Value of a Mysterious Function Closest to Target (Hard)
  32. Find Building Where Alice and Bob Can Meet (Hard)
  33. Find Subarray With Bitwise OR Closest to K (Hard)
  34. Find X Value of Array II (Hard)
  35. Handling Sum Queries After Update (Hard)
  36. K Empty Slots (Hard)
  37. Longest Balanced Subarray II (Hard)
  38. Longest Increasing Subsequence II (Hard)
  39. Longest Substring of One Repeating Character (Hard)
  40. Make Array Empty (Hard)
  41. Maximize Subarray Sum After Removing All Occurrences of One Element (Hard)
  42. Maximize Subarrays After Removing One Conflicting Pair (Hard)
  43. Maximum Area Rectangle With Point Constraints II (Hard)
  44. Maximum Balanced Subsequence Sum (Hard)
  45. Maximum Profitable Triplets With Increasing Prices II (Hard)
  46. Maximum Sum of Subsequence With Non-adjacent Elements (Hard)
  47. Minimum Stability Factor of Array (Hard)
  48. Minimum Sum of Values by Dividing Array (Hard)
  49. My Calendar III (Hard)
  50. Number of Pairs Satisfying Inequality (Hard)
  51. Number of Subarrays With AND Value of K (Hard)
  52. Online Majority Element In Subarray (Hard)
  53. Peaks in Array (Hard)
  54. Range Module (Hard)
  55. Rectangle Area II (Hard)
  56. Reverse Pairs (Hard)
  57. Separate Squares II (Hard)
  58. Shortest Path in a Weighted Tree (Hard)
  59. Subarrays Distinct Element Sum of Squares II (Hard)
  60. The Skyline Problem (Hard)

Companies that ask segment tree 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