Segment Tree Problems
Master segment tree problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 40 problems in this category.
Total Problems: 40
Easy: 1
Medium: 8
Hard: 31
Showing 40 of 40 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Segment Tree LeetCode Problems List
- 315. Count of Smaller Numbers After Self - Hard - Segment TreeGiven an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 673. Number of Longest Increasing Subsequence - Medium - Segment TreeGiven an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing.... Topics: Array, Dynamic Programming, Binary Indexed Tree, Segment Tree
- 715. Range Module - Hard - Segment TreeA Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and query abo... Topics: Design, Segment Tree, Ordered Set
- 2526. Longest Increasing Subsequence II - Hard - Segment TreeYou are given an integer array nums and an integer k. Find the longest subsequence of nums that meets the following requirements: The subsequence is s... Topics: Array, Divide and Conquer, Dynamic Programming, Binary Indexed Tree, Segment Tree, Queue, Monotonic Queue
- 699. Falling Squares - Hard - Segment TreeThere are several squares being dropped onto the X-axis of a 2D plane. You are given a 2D integer array positions where positions[i] = [lefti, sideLen... Topics: Array, Segment Tree, Ordered Set
- 3790. Fruits Into Baskets II - Easy - Segment TreeYou are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and bask... Topics: Array, Binary Search, Segment Tree, Simulation, Ordered Set
- 218. The Skyline Problem - Hard - Segment TreeA city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and ... Topics: Array, Divide and Conquer, Binary Indexed Tree, Segment Tree, Line Sweep, Heap (Priority Queue), Ordered Set
- 2357. Count Integers in Intervals - Hard - Segment TreeGiven an empty set of intervals, implement a data structure that can: Add an interval to the set of intervals. Count the number of integers that are p... Topics: Design, Segment Tree, Ordered Set
- 3435. Block Placement Queries - Hard - Segment TreeThere exists an infinite number line, with its origin at 0 and extending towards the positive x-axis. You are given a 2D array queries, which contains... Topics: Array, Binary Search, Binary Indexed Tree, Segment Tree
- 406. Queue Reconstruction by Height - Medium - Segment TreeYou are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] rep... Topics: Array, Binary Indexed Tree, Segment Tree, Sorting
- 327. Count of Range Sum - Hard - Segment TreeGiven an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) ... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 3181. Find Building Where Alice and Bob Can Meet - Hard - Segment TreeYou are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building. If a person is in building i... Topics: Array, Binary Search, Stack, Binary Indexed Tree, Segment Tree, Heap (Priority Queue), Monotonic Stack
- 3423. Maximum Sum of Subsequence With Non-adjacent Elements - Hard - Segment TreeYou are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi]. For query i, we first set nu... Topics: Array, Divide and Conquer, Dynamic Programming, Segment Tree
- 307. Range Sum Query - Mutable - Medium - Segment TreeGiven an integer array nums, handle multiple queries of the following types: Update the value of an element in nums. Calculate the sum of the elements... Topics: Array, Divide and Conquer, Design, Binary Indexed Tree, Segment Tree
- 732. My Calendar III - Hard - Segment TreeA k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.) You are given some event... Topics: Binary Search, Design, Segment Tree, Prefix Sum, Ordered Set
- 2319. Longest Substring of One Repeating Character - Hard - Segment TreeYou are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIn... Topics: Array, String, Segment Tree, Ordered Set
- 3791. Fruits Into Baskets III - Medium - Segment TreeYou are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and bask... Topics: Array, Binary Search, Segment Tree, Ordered Set
- 880. Rectangle Area II - Hard - Segment TreeYou are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coord... Topics: Array, Segment Tree, Line Sweep, Ordered Set
- 493. Reverse Pairs - Hard - Segment TreeGiven an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where: 0 <= i < j < nums.length and nums... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 2703. Handling Sum Queries After Update - Hard - Segment TreeYou are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries. There are three types of queries: For a query of type 1, queries... Topics: Array, Segment Tree
- 3941. Number of Integers With Popcount-Depth Equal to K II - Hard - Segment TreeYou are given an integer array nums. For any positive integer x, define the following sequence: p0 = x pi+1 = popcount(pi) for all i >= 0, where popco... Topics: Array, Divide and Conquer, Binary Indexed Tree, Segment Tree
- 1772. Create Sorted Array through Instructions - Hard - Segment TreeGiven an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums.... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 1728. Fancy Sequence - Hard - Segment TreeWrite an API that generates fancy sequences using the append, addAll, and multAll operations. Implement the Fancy class: Fancy() Initializes the objec... Topics: Math, Design, Segment Tree
- 3139. Subarrays Distinct Element Sum of Squares II - Hard - Segment TreeYou are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting ... Topics: Array, Dynamic Programming, Binary Indexed Tree, Segment Tree
- 3688. Maximize Subarray Sum After Removing All Occurrences of One Element - Hard - Segment TreeYou are given an integer array nums. You can do the following operation on the array at most once: Choose any integer x such that nums remains non-emp... Topics: Array, Dynamic Programming, Segment Tree
- 3920. Minimum Stability Factor of Array - Hard - Segment TreeYou are given an integer array nums and an integer maxC. A subarray is called stable if the highest common factor (HCF) of all its elements is greater... Topics: Array, Math, Binary Search, Greedy, Segment Tree, Number Theory
- 1645. Find a Value of a Mysterious Function Closest to Target - Hard - Segment TreeWinston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that m... Topics: Array, Binary Search, Bit Manipulation, Segment Tree
- 2513. Number of Pairs Satisfying Inequality - Hard - Segment TreeYou are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that: 0 <= i < j... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 2765. Make Array Empty - Hard - Segment TreeYou are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty: If the first e... Topics: Array, Binary Search, Greedy, Binary Indexed Tree, Segment Tree, Sorting, Ordered Set
- 1511. Count Number of Teams - Medium - Segment TreeThere are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the ... Topics: Array, Dynamic Programming, Binary Indexed Tree, Segment Tree
- 2280. Count Good Triplets in an Array - Hard - Segment TreeYou are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1]. A good triplet is a set of 3 dis... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 3840. Find X Value of Array II - Hard - Segment TreeYou are given an array of positive integers nums and a positive integer k. You are also given a 2D array queries, where queries[i] = [indexi, valuei, ... Topics: Array, Math, Segment Tree
- 1629. Minimum Possible Integer After at Most K Adjacent Swaps On Digits - Hard - Segment TreeYou are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the in... Topics: String, Greedy, Binary Indexed Tree, Segment Tree
- 3829. Shortest Path in a Weighted Tree - Hard - Segment TreeYou are given an integer n and an undirected, weighted tree rooted at node 1 with n nodes numbered from 1 to n. This is represented by a 2D array edge... Topics: Array, Tree, Depth-First Search, Binary Indexed Tree, Segment Tree
- 1294. Range Frequency Queries - Medium - Segment TreeDesign a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrence... Topics: Array, Hash Table, Binary Search, Design, Segment Tree
- 3878. Maximize Count of Distinct Primes After Split - Hard - Segment TreeYou are given an integer array nums having length n and a 2D integer array queries where queries[i] = [idx, val]. For each query: Update nums[idx] = v... Topics: Array, Math, Segment Tree, Number Theory
- 2380. Booking Concert Tickets in Groups - Hard - Segment TreeA concert hall has n rows numbered from 0 to n - 1, each with m seats, numbered from 0 to m - 1. You need to design a ticketing system that can alloca... Topics: Binary Search, Design, Binary Indexed Tree, Segment Tree
- 731. My Calendar II - Medium - Segment TreeYou are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking. A triple booking h... Topics: Array, Binary Search, Design, Segment Tree, Prefix Sum, Ordered Set
- 3789. Maximize Subarrays After Removing One Conflicting Pair - Hard - Segment TreeYou are given an integer n which represents an array nums containing the numbers from 1 to n in order. Additionally, you are given a 2D array conflict... Topics: Array, Segment Tree, Enumeration, Prefix Sum
- 729. My Calendar I - Medium - Segment TreeYou are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking h... Topics: Array, Binary Search, Design, Segment Tree, Ordered Set
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems