## Queries to check whether a given digit is present in the given Range

Pre-requisites: Segment Tree Given an array of digits arr[]. Given a number of range [L, R] and a digit X with each range. The task… 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
- Difference Array | Range update query in O(1)
- Find element at given index after a number of rotations
- 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)
- Constant time range add operation on an array
- Queries for counts of array elements with values in given range
- Min-Max Range Queries in Array
- Binary Indexed Tree : Range Update and Range Queries
- Sparse Table
- Count Primes in Ranges
- Number of elements less than or equal to a given number in a given subarray
- Persistent Segment Tree | Set 1 (Introduction)
- Binary Indexed Tree : Range Updates and Point Queries
- Range LCM Queries
- Segment Tree | Set 2 (Range Maximum Query with Node Update)
- LCA for general or n-ary trees (Sparse Matrix DP approach < O(nlogn), O(logn)>)
- Range Queries for Frequencies of array elements
- GCDs of given index ranges in an array
- Heavy Light Decomposition | Set 1 (Introduction)
- LCA for n-ary Tree | Constant Query O(1)
- Queries for number of distinct elements in a subarray
- Number of elements greater than K in the range L to R using Fenwick Tree (Offline queries)
- Number of primes in a subarray (with updates)
- Range sum query using Sparse Table

Pre-requisites: Segment Tree Given an array of digits arr[]. Given a number of range [L, R] and a digit X with each range. The task… Read More »

Given an array A having N elements and two integers L and R where, and . You can choose any element of the array (let’s… Read More »

Given N ranges of L-R. The task is to print the number which occurs the maximum number of times in the given ranges. Note: 1… Read More »

Given N ranges and Q queries consisting of numbers. Every range consists of L and R. The task is to check if the given number… Read More »

Given Q queries and an empty list. The queries can be of two types: addToList(x) : Add x to your list. removeFromList(x) : Remove x… Read More »

Given an array arr[0 . . . n-1]. The task is to perform the following operation: Find the maximum of elements from index l to… Read More »

Given an array of N positive integers. The task is to perform the following operations according to the type of query given. 1. Print the… Read More »

Prerequisites: Fenwick Tree (Binary Indexed Tree) Given an array of N numbers, and a number of queries where each query will contain three numbers(l, r… Read More »

We have discussed recursive segment tree implementation. In this post, iterative implementation is discussed. Let us consider the following problem understand Segment Trees. We have… Read More »

We have an array of integers and a set of range queries. For every query, we need to find product of elements in the given… Read More »

Given an array of N integers and Q queries. Every query consists of L and R. The task is to print the second smallest element… Read More »

Given an array of size N and Q queries, each query consists of L, R, and K(consider 1 based-indexing for L and R). The task… Read More »

Given an array of n elements and q range queries (range sum in this article) with no updates, task is to answer these queries with… Read More »

Given an array of N numbers and Q queries, each query consists of L and R. We need to write a program that prints the… Read More »

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 »