## Queries to update a given index and find gcd in range

Given an array arr[] of N integers and queries Q. Queries are of two types: Update a given index ind by X. Find the gcd… Read More »

- Queries for elements having values within the range A to B in the given index range using Segment Tree
- Dynamic Segment Trees : Online Queries for Range Sum with Point Updates
- Sum of prime numbers in range [L, R] from given Array for Q queries
- Queries to check if any non-repeating element exists within range [L, R] of an Array
- Lexicographical smallest number after at most K consecutive swaps
- Sum and Maximum of elements in array from [L, R] before and after updates
- Range Sum and Update in Array : Segment Tree using Stack
- Maximum pair sum in the given index ranges of an Array
- Range Queries for number of Armstrong numbers in an array with updates
- Array range queries to count the number of Fibonacci numbers with updates
- Maximum of all subarrays of size K using Segment Tree
- Binary Array Range Queries to find the minimum distance between two Zeros
- Array Range Queries to find the Maximum Armstrong number with updates
- Queries for greatest pair sum in the given index range using Segment Tree
- Queries for the count of even digit sum elements in the given range using Segment Tree.
- Count of divisors of product of an Array in range L to R for Q queries
- Find the element having maximum set bits in the given range for Q queries
- Find array sum using Bitwise OR after splitting given array in two halves after K circular shifts
- Array range queries to find the number of perfect square elements with updates
- Maximum distance between two 1s in a Binary Array in a given range
- Count of distinct numbers in an Array in a range for Online Queries using Merge Sort Tree
- Array Range Queries to count Powerful numbers with updates
- Range Queries to count the number of even parity values with updates
- Range Queries to find the Element having Maximum Digit Sum
- Array range queries to find the maximum Fibonacci number with updates
- Range Update Queries to XOR with 1 in a Binary Array.

Given an array arr[] of N integers and queries Q. Queries are of two types: Update a given index ind by X. Find the gcd… Read More »

Given an array arr[] of size N. There are two types of operations: Update(l, r, x) : Increment the a[i] (l <= i <= r)… Read More »

Given an integer K and an array arr[], the task is to count all the sub-arrays whose product is divisible by K. Examples: Input: arr[]… Read More »

Given an unsorted array, trim the array such that twice of minimum is greater than the maximum in the trimmed array. Elements should be removed… Read More »

Given an array arr[] of N integers and Q queries. Each query consists of 3 integers L, R and K. You can move from index… Read More »

Given an array arr[] and an integer K, the task is to count the number of sub-arrays having bitwise OR ≥ K. Examples: Input: arr[]… Read More »

Given an array of N integers, the task is to perform the following two operations on the given array: query(start, end) : Print the number… Read More »

Given an array arr[] of N integers and number of queries Q. The task is to answer three types of queries. Update [l, r] –… Read More »

Given an array of integers arr, the task is to count the number of inversions in the array. If A[i] > A[j] and i <… Read More »

Given an array ‘arr’ all the numbers of which are initialized to ‘0’ then the array can be updated at any time in the following… Read More »

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 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 »

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 »

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 »