## Queries for elements greater than K in the given index range using Segment Tree

Given an array arr[] of N elements and a number of queries where each query will contain three integers L, R and K. For each… Read More »

## Find the count of distinct numbers in a range

Given an array of size N containing numbers only from 0 to 63, and you are asked Q queries regarding it. Queries are as follows:… Read More »

## Multiplication on Array : Range update query in O(1)

Consider an array A[] of integers and the following two types of queries. update(l, r, x): multiply x to all values from A[l] to A[r]… Read More »

## Queries to count integers in a range [L, R] such that their digit sum is prime and divisible by K

Given Q queries and an integer K where each query consists of a range [L, R] and the task is to find the count of… Read More »

## Minimum difference between any two primes from the given range

Given two integers L and R, the task is to find the minimum difference between any two prime numbers in the range [L, R]. Examples:… Read More »

## Queries to find the count of integers in a range that contain the given pattern

Given a binary pattern patt and Q queries where each query consists of a range [L, R], for every query the task is to find… Read More »

## Sum of numbers in a range [L, R] whose count of divisors is prime

Given Q queries where each query consists of an integer range [L, R], the task is to find the sum of the integers from the… Read More »

## Range maximum query using Sparse Table

Given an array arr[], the task is to answer queries to find the maximum of all the elements in the index range arr[L…R]. Examples: Input:… Read More »

## Queries to check whether all the elements in the given range occurs even number of times

Given an array arr[] containing N integers and there are Q queries where each query consists of a range [L, R]. The task is to… Read More »

## Sum of all natural numbers from L to R ( for large values of L and R )

Given two very large numbers L and R where L ≤ R, the task is to compute the sum of all the natural numbers from… Read More »

## Queries for number of distinct elements in a subarray | Set 2

Given an array arr[] of N integers and Q queries. Each query can be represented by two integers L and R. The task is to… Read More »

## Kth smallest element in a subarray

Given an array arr of size N. The task is to find the kth smallest element in the subarray(l to r, both inclusive). Note :… Read More »

## Queries to check whether all the elements can be made positive by flipping signs exactly K times

Given an integer array arr[], and some queries consisting of an integer K, the task is to determine if its possible to make all the… Read More »

## Queries to find the last non-repeating character in the sub-string of a given string

Given a string str, the task is to answer Q queries where every query consists of two integers L and R and we have to… Read More »

## Queries for bitwise AND in the index range [L, R] of the given array

Given an array arr[] of N and Q queries consisting of a range [L, R]. the task is to find the bit-wise AND of all… Read More »