## Range query for count of set bits

Given an array of positive integer and q query which contains two integers, L & R. Task is to find the number of set bits… Read More »

- Segment Tree | Set 1 (Sum of given range)
- Binary Indexed Tree or Fenwick Tree
- Segment Tree | Set 2 (Range Minimum Query)
- Lazy Propagation in Segment Tree
- Find element at given index after a number of rotations
- Difference Array | Range update query in O(1)
- MO's Algorithm (Query Square Root Decomposition) | Set 1 (Introduction)
- Queries on Left and Right Circular shift on array
- Range Minimum Query (Square Root Decomposition and Sparse Table)
- Sqrt (or Square Root) Decomposition Technique | Set 1 (Introduction)
- Queries for counts of array elements with values in given range
- Constant time range add operation on an array
- Sparse Table
- Min-Max Range Queries in Array
- Binary Indexed Tree : Range Update and Range Queries
- Count Primes in Ranges
- Number of elements less than or equal to a given number in a given subarray
- LCA for general or n-ary trees (Sparse Matrix DP approach < O(nlogn), O(logn)>)
- Persistent Segment Tree | Set 1 (Introduction)
- Range LCM Queries
- Binary Indexed Tree : Range Updates and Point Queries
- Range Queries for Frequencies of array elements
- Segment Tree | Set 2 (Range Maximum Query with Node Update)
- GCDs of given index ranges in an array
- Heavy Light Decomposition | Set 1 (Introduction)
- LCA for n-ary Tree | Constant Query O(1)
- Segment Tree | Set 3 (XOR of given range)
- Total numbers with no repeated digits in a range
- Range sum query using Sparse Table
- Array range queries over range queries

Given an array of positive integer and q query which contains two integers, L & R. Task is to find the number of set bits… Read More »

Given an array arr[0 . . . n-1]. Find the maximum of elements from index l to r where 0 <= l <= r <=… Read More »

Consider an array of size n with initial 0 values. How many indices will contain value at least x after performing m range updates. In… Read More »

Given N numbers and Q queries, each query consists of L and R. Task is to write a program which prints the count of numbers… Read More »

Given a rectangular matrix M[0…n-1][0…m-1], and queries are asked to find the sum / minimum / maximum on some sub-rectangles M[a…b][e…f], as well as queries… Read More »

Given N pieces of chessboard all being ‘white’ and a number of queries Q. There are two types of queries : Update : Given indices… Read More »

You are given a sequence of N integers and Q queries. In each query, you are given two parameters L and R. You have to… Read More »

Given an array of numbers of size N and Q queries. Each query or a range can be represented by L (LeftIndex) and R(RightIndex). Find… Read More »

Given an array of N integers, the task is to perform the following two queries: query(start, end) : Print the number of prime numbers in… Read More »

Given an array of N elements and Q queries of the form L R X. For each query, you have to output if the element… Read More »

Given a bracket sequence or in other words a string S of length n, consisting of characters ‘(‘ and ‘)’. Find length of the maximum… Read More »

Given an array of N numbers, the task is to answer Q queries of the following type:- query(start, end) = Number of times a number… Read More »

Given an array A of N integers. You have to answer two types of queries : 1. Update [l, r] – for every i in… Read More »

Given an array of n integers in non-decreasing order. Find the number of occurrences of the most frequent value within a given range. Examples: Input… Read More »

Given N numbers and Q queries, every query consists of L and R, task is to find the number of such integers i (L<=i<R) such… Read More »