Segment Tree
Segment Tree
Twenty-five questions on segment trees, for range queries and updates in logarithmic time.
Fruits Into Baskets II
easyYou 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 baskets[j] represents the...
Count Number of Teams
mediumThere are n soldiers standing in a line.
Fruits Into Baskets III
mediumYou 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 baskets[j] represents the...
Maximum Area Rectangle With Point Constraints I
mediumYou are given an array points where points[i] = [xi, yi] represents the coordinates of a point on an infinite plane.
Minimum Number of Valid Strings to Form Target I
mediumYou are given an array of strings words and a string target.
Number of Longest Increasing Subsequence
mediumGiven an integer array nums, return the number of longest increasing subsequences.
Queue Reconstruction by Height
mediumYou are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order).
Block Placement Queries
hardThere exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.
Count Good Triplets in an Array
hardYou are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].
Count Non-Decreasing Subarrays After K Operations
hardYou are given an array nums of n integers and an integer k.
Count of Range Sum
hardGiven an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive.
Count of Smaller Numbers After Self
hardGiven an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].
Create Sorted Array through Instructions
hardGiven an integer array instructions, you are asked to create a sorted array from the elements in instructions.
Delivering Boxes from Storage to Ports
hardYou have the task of delivering some boxes from storage to their ports using only one ship.
Distribute Elements Into Two Arrays II
hardYou are given a 1-indexed array of integers nums of length n.
Falling Squares
hardThere are several squares being dropped onto the X-axis of a 2D plane.
Find a Value of a Mysterious Function Closest to Target
hardWinston was given the above mysterious function func.
Find Building Where Alice and Bob Can Meet
hardYou are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.
Find Subarray With Bitwise OR Closest to K
hardYou are given an array nums and an integer k.
Find X Value of Array II
hardYou are given an array of positive integers nums and a positive integer k.
Handling Sum Queries After Update
hardYou are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries.
Longest Increasing Subsequence II
hardYou are given an integer array nums and an integer k.
Longest Substring of One Repeating Character
hardYou are given a 0-indexed string s.
Make Array Empty
hardYou are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty: Return an integer denoting the number of...
Maximize Active Section with Trade II
hardYou are given a binary string s of length n, where: You can perform at most one trade to maximize the number of active sections in s.