Fenwick Tree

Twenty questions on Fenwick trees (binary indexed trees), a compact alternative to segment trees for prefix-sum queries.

Count Number of Rectangles Containing Each Point

medium
You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi.

Count Number of Teams

medium
There are n soldiers standing in a line.

Maximum Area Rectangle With Point Constraints I

medium
You are given an array points where points[i] = [xi, yi] represents the coordinates of a point on an infinite plane.

Number of Longest Increasing Subsequence

medium
Given an integer array nums, return the number of longest increasing subsequences.

Queries on a Permutation With Key

medium
Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: Return an array...

Queue Reconstruction by Height

medium
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order).

Alternating Groups III

hard
There are some red and blue tiles arranged circularly.

Block Placement Queries

hard
There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.

Count Good Triplets in an Array

hard
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].

Count Increasing Quadruplets

hard
Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.

Count of Range Sum

hard
Given 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

hard
Given 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

hard
Given an integer array instructions, you are asked to create a sorted array from the elements in instructions.

Distribute Elements Into Two Arrays II

hard
You are given a 1-indexed array of integers nums of length n.

Find Building Where Alice and Bob Can Meet

hard
You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.

Find the Longest Valid Obstacle Course at Each Position

hard
You want to build some obstacle courses.

Longest Increasing Subsequence II

hard
You are given an integer array nums and an integer k.

Make Array Empty

hard
You 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...

Maximum Area Rectangle With Point Constraints II

hard
There are n points on an infinite plane.

Maximum Balanced Subsequence Sum

hard
You are given a 0-indexed integer array nums.