# Segment Tree DSA Problems

> 60 Segment Tree coding problems for placements and interviews, sorted easiest first, with hints and company tags. Free practice on InternHack.

Canonical: https://www.internhack.in/learn/dsa/segment-tree
Last updated: 2026-11-28

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](https://www.internhack.in/learn/dsa/problem/fruits-into-baskets-ii) (Easy)
2. [Count Number of Teams](https://www.internhack.in/learn/dsa/problem/count-number-of-teams) (Medium)
3. [Count Subarrays With More Ones Than Zeros](https://www.internhack.in/learn/dsa/problem/count-subarrays-with-more-ones-than-zeros) (Medium)
4. [Fruits Into Baskets III](https://www.internhack.in/learn/dsa/problem/fruits-into-baskets-iii) (Medium)
5. [Longest Balanced Subarray I](https://www.internhack.in/learn/dsa/problem/longest-balanced-subarray-i) (Medium)
6. [Longest Uploaded Prefix](https://www.internhack.in/learn/dsa/problem/longest-uploaded-prefix) (Medium)
7. [Maximum Area Rectangle With Point Constraints I](https://www.internhack.in/learn/dsa/problem/maximum-area-rectangle-with-point-constraints-i) (Medium)
8. [Maximum Profitable Triplets With Increasing Prices I](https://www.internhack.in/learn/dsa/problem/maximum-profitable-triplets-with-increasing-prices-i) (Medium)
9. [Minimum Number of Valid Strings to Form Target I](https://www.internhack.in/learn/dsa/problem/minimum-number-of-valid-strings-to-form-target-i) (Medium)
10. [My Calendar I](https://www.internhack.in/learn/dsa/problem/my-calendar-i) (Medium)
11. [My Calendar II](https://www.internhack.in/learn/dsa/problem/my-calendar-ii) (Medium)
12. [Number of Longest Increasing Subsequence](https://www.internhack.in/learn/dsa/problem/number-of-longest-increasing-subsequence) (Medium)
13. [Queue Reconstruction by Height](https://www.internhack.in/learn/dsa/problem/queue-reconstruction-by-height) (Medium)
14. [Range Frequency Queries](https://www.internhack.in/learn/dsa/problem/range-frequency-queries) (Medium)
15. [Range Sum Query - Mutable](https://www.internhack.in/learn/dsa/problem/range-sum-query-mutable) (Medium)
16. [Range Sum Query 2D - Mutable](https://www.internhack.in/learn/dsa/problem/range-sum-query-2d-mutable) (Medium)
17. [Amount of New Area Painted Each Day](https://www.internhack.in/learn/dsa/problem/amount-of-new-area-painted-each-day) (Hard)
18. [Block Placement Queries](https://www.internhack.in/learn/dsa/problem/block-placement-queries) (Hard)
19. [Booking Concert Tickets in Groups](https://www.internhack.in/learn/dsa/problem/booking-concert-tickets-in-groups) (Hard)
20. [Count Good Triplets in an Array](https://www.internhack.in/learn/dsa/problem/count-good-triplets-in-an-array) (Hard)
21. [Count Integers in Intervals](https://www.internhack.in/learn/dsa/problem/count-integers-in-intervals) (Hard)
22. [Count Non-Decreasing Subarrays After K Operations](https://www.internhack.in/learn/dsa/problem/count-non-decreasing-subarrays-after-k-operations) (Hard)
23. [Count of Range Sum](https://www.internhack.in/learn/dsa/problem/count-of-range-sum) (Hard)
24. [Count of Smaller Numbers After Self](https://www.internhack.in/learn/dsa/problem/count-of-smaller-numbers-after-self) (Hard)
25. [Count the Number of K-Big Indices](https://www.internhack.in/learn/dsa/problem/count-the-number-of-k-big-indices) (Hard)
26. [Create Sorted Array through Instructions](https://www.internhack.in/learn/dsa/problem/create-sorted-array-through-instructions) (Hard)
27. [Delivering Boxes from Storage to Ports](https://www.internhack.in/learn/dsa/problem/delivering-boxes-from-storage-to-ports) (Hard)
28. [Distribute Elements Into Two Arrays II](https://www.internhack.in/learn/dsa/problem/distribute-elements-into-two-arrays-ii) (Hard)
29. [Falling Squares](https://www.internhack.in/learn/dsa/problem/falling-squares) (Hard)
30. [Fancy Sequence](https://www.internhack.in/learn/dsa/problem/fancy-sequence) (Hard)
31. [Find a Value of a Mysterious Function Closest to Target](https://www.internhack.in/learn/dsa/problem/find-a-value-of-a-mysterious-function-closest-to-target) (Hard)
32. [Find Building Where Alice and Bob Can Meet](https://www.internhack.in/learn/dsa/problem/find-building-where-alice-and-bob-can-meet) (Hard)
33. [Find Subarray With Bitwise OR Closest to K](https://www.internhack.in/learn/dsa/problem/find-subarray-with-bitwise-or-closest-to-k) (Hard)
34. [Find X Value of Array II](https://www.internhack.in/learn/dsa/problem/find-x-value-of-array-ii) (Hard)
35. [Handling Sum Queries After Update](https://www.internhack.in/learn/dsa/problem/handling-sum-queries-after-update) (Hard)
36. [K Empty Slots](https://www.internhack.in/learn/dsa/problem/k-empty-slots) (Hard)
37. [Longest Balanced Subarray II](https://www.internhack.in/learn/dsa/problem/longest-balanced-subarray-ii) (Hard)
38. [Longest Increasing Subsequence II](https://www.internhack.in/learn/dsa/problem/longest-increasing-subsequence-ii) (Hard)
39. [Longest Substring of One Repeating Character](https://www.internhack.in/learn/dsa/problem/longest-substring-of-one-repeating-character) (Hard)
40. [Make Array Empty](https://www.internhack.in/learn/dsa/problem/make-array-empty) (Hard)
41. [Maximize Subarray Sum After Removing All Occurrences of One Element](https://www.internhack.in/learn/dsa/problem/maximize-subarray-sum-after-removing-all-occurrences-of-one-element) (Hard)
42. [Maximize Subarrays After Removing One Conflicting Pair](https://www.internhack.in/learn/dsa/problem/maximize-subarrays-after-removing-one-conflicting-pair) (Hard)
43. [Maximum Area Rectangle With Point Constraints II](https://www.internhack.in/learn/dsa/problem/maximum-area-rectangle-with-point-constraints-ii) (Hard)
44. [Maximum Balanced Subsequence Sum](https://www.internhack.in/learn/dsa/problem/maximum-balanced-subsequence-sum) (Hard)
45. [Maximum Profitable Triplets With Increasing Prices II](https://www.internhack.in/learn/dsa/problem/maximum-profitable-triplets-with-increasing-prices-ii) (Hard)
46. [Maximum Sum of Subsequence With Non-adjacent Elements](https://www.internhack.in/learn/dsa/problem/maximum-sum-of-subsequence-with-non-adjacent-elements) (Hard)
47. [Minimum Stability Factor of Array](https://www.internhack.in/learn/dsa/problem/minimum-stability-factor-of-array) (Hard)
48. [Minimum Sum of Values by Dividing Array](https://www.internhack.in/learn/dsa/problem/minimum-sum-of-values-by-dividing-array) (Hard)
49. [My Calendar III](https://www.internhack.in/learn/dsa/problem/my-calendar-iii) (Hard)
50. [Number of Pairs Satisfying Inequality](https://www.internhack.in/learn/dsa/problem/number-of-pairs-satisfying-inequality) (Hard)
51. [Number of Subarrays With AND Value of K](https://www.internhack.in/learn/dsa/problem/number-of-subarrays-with-and-value-of-k) (Hard)
52. [Online Majority Element In Subarray](https://www.internhack.in/learn/dsa/problem/online-majority-element-in-subarray) (Hard)
53. [Peaks in Array](https://www.internhack.in/learn/dsa/problem/peaks-in-array) (Hard)
54. [Range Module](https://www.internhack.in/learn/dsa/problem/range-module) (Hard)
55. [Rectangle Area II](https://www.internhack.in/learn/dsa/problem/rectangle-area-ii) (Hard)
56. [Reverse Pairs](https://www.internhack.in/learn/dsa/problem/reverse-pairs) (Hard)
57. [Separate Squares II](https://www.internhack.in/learn/dsa/problem/separate-squares-ii) (Hard)
58. [Shortest Path in a Weighted Tree](https://www.internhack.in/learn/dsa/problem/shortest-path-in-a-weighted-tree) (Hard)
59. [Subarrays Distinct Element Sum of Squares II](https://www.internhack.in/learn/dsa/problem/subarrays-distinct-element-sum-of-squares-ii) (Hard)
60. [The Skyline Problem](https://www.internhack.in/learn/dsa/problem/the-skyline-problem) (Hard)

## Companies that ask segment tree problems

- [Google](https://www.internhack.in/learn/dsa/companies/google): 39 of these problems
- [Amazon](https://www.internhack.in/learn/dsa/companies/amazon): 25 of these problems
- [Meta](https://www.internhack.in/learn/dsa/companies/meta): 14 of these problems
- [Bloomberg](https://www.internhack.in/learn/dsa/companies/bloomberg): 13 of these problems
- [Microsoft](https://www.internhack.in/learn/dsa/companies/microsoft): 10 of these problems
- [Uber](https://www.internhack.in/learn/dsa/companies/uber): 7 of these problems
- [Tiktok](https://www.internhack.in/learn/dsa/companies/tiktok): 4 of these problems
- [IBM](https://www.internhack.in/learn/dsa/companies/ibm): 3 of these problems
- [Apple](https://www.internhack.in/learn/dsa/companies/apple): 3 of these problems
- [Intuit](https://www.internhack.in/learn/dsa/companies/intuit): 3 of these problems
- [Autodesk](https://www.internhack.in/learn/dsa/companies/autodesk): 2 of these problems
- [Linkedin](https://www.internhack.in/learn/dsa/companies/linkedin): 2 of these problems

## Before your interview

Most resumes are filtered by software before a recruiter reads them. [Check your resume ATS score free](https://www.internhack.in/ats-score/try), no signup needed.

## Other DSA topics

- [Array](https://www.internhack.in/learn/dsa/array) (1869)
- [String](https://www.internhack.in/learn/dsa/string) (775)
- [Hash Table](https://www.internhack.in/learn/dsa/hash-table) (708)
- [Math](https://www.internhack.in/learn/dsa/math) (564)
- [Dynamic Programming](https://www.internhack.in/learn/dsa/dynamic-programming) (557)
- [Sorting](https://www.internhack.in/learn/dsa/sorting) (464)
- [Greedy](https://www.internhack.in/learn/dsa/greedy) (407)
- [Depth-First Search](https://www.internhack.in/learn/dsa/depth-first-search) (314)
- [Binary Search](https://www.internhack.in/learn/dsa/binary-search) (298)
- [Matrix](https://www.internhack.in/learn/dsa/matrix) (246)
- [Breadth-First Search](https://www.internhack.in/learn/dsa/breadth-first-search) (245)
- [Bit Manipulation](https://www.internhack.in/learn/dsa/bit-manipulation) (238)
- [Tree](https://www.internhack.in/learn/dsa/tree) (235)
- [Two Pointers](https://www.internhack.in/learn/dsa/two-pointers) (217)
- [Prefix Sum](https://www.internhack.in/learn/dsa/prefix-sum) (204)
- [Database](https://www.internhack.in/learn/dsa/database) (197)
- [Heap (Priority Queue)](https://www.internhack.in/learn/dsa/heap-priority-queue) (196)
- [Simulation](https://www.internhack.in/learn/dsa/simulation) (177)
- [Counting](https://www.internhack.in/learn/dsa/counting) (174)
- [Binary Tree](https://www.internhack.in/learn/dsa/binary-tree) (169)

## Related

- [Home](https://www.internhack.in/)
- [Learn](https://www.internhack.in/learn)
- [DSA](https://www.internhack.in/learn/dsa)
