# Tag Archives: array-range-queries

## Count of natural numbers in range [L, R] which are relatively prime with N

Given three integers N, L, and R. The task is to calculate the number of natural numbers in the range [L, R] (both inclusive) which… Read More »

## C/C++ Program to find Prime Numbers between given range

Given two numbers L and R, the task is to find the prime numbers between L and R. Examples: Input: L = 1, R =… Read More »

## XOR of a subarray (range of elements) | Set 2

Given an array integer arr[] of size N and Q queries. Each query is of the form (L, R), where L and R are indices… Read More »

## String Range Queries to count number of distinct characters with updates

Given a string S of length N, and Q queries of the following type: Type 1: 1 i X Update the i-th character of the… Read More »

## Count of all values of N in [L, R] such that count of primes upto N is also prime

Given two positive integers L and R, the task is to find out the total number of values between range [L, R] such that the… Read More »

## Most frequent element in Array after replacing given index by K for Q queries

Given an array arr[] of size N, and Q queries of the form {i, k} for which, the task is to print the most frequent… Read More »

## Smallest index in given range of indices which is not equal to X

Given an integer array arr[] of size N, and Q queries of the form of {L, R, X}, the task is to find the smallest… Read More »

## Count of elements having odd number of divisors in index range [L, R] for Q queries

Given an array arr[] of N positive integers and the number of queries Q, each query contains two numbers L and R. The task is… Read More »

## Array sum after replacing all occurrences of X by Y for Q queries

Given an integer array arr[] and Q queries, the task is to find the sum of the array for each query of the following type:… Read More »

## Largest interval in an Array that contains the given element X for Q queries

Given an array arr[] of N elements and Q queries of the form [X]. For each query, the task is to find the largest interval… Read More »

## Sum of multiples of Array elements within a given range [L, R]

Given an array arr[] of positive integers and two integers L and R, the task is to find the sum of all multiples of the… Read More »

## Find elements in a given range having at least one odd divisor

Given two integers N and M, the task is to print all elements in the range [N, M] having at least one odd divisor. Examples:… Read More »

## Count of distinct numbers in an Array in a range for Online Queries using Merge Sort Tree

Given an array arr[] of size N and Q queries of the form [L, R], the task is to find the number of distinct values… Read More »

## Minimum count of increment of K size subarrays required to form a given Array

Given an array arr[] and an integer K, the task is to find the minimum number of operations required to change an array B of… Read More »

## Sum of all array elements less than X and greater than Y for Q queries

Given a sorted array arr[], and a set Q having M queries, where each query has values X and Y, the task is to find… Read More »