## Range Sum Queries and Update with Square Root

Given an array A of N integers and number of queries Q. You have to answer two types of queries. Update [l, r] – for… Read More »

## Number of elements greater than K in the range L to R using Fenwick Tree (Offline queries)

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 »

## Count inversions of size k in a given array

Given an array of n distinct integers and an integer k. Find out the number of sub-sequences of a such that , and . In… Read More »

## XOR of numbers that appeared even number of times in given Range

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 »

## Sum of Interval and Update with Number of Divisors

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 »

## Array range queries over range queries

Given an array of size n and a give set of commands of size m. The commands are enumerated from 1 to m. These commands… Read More »

## Queries for number of distinct elements in a subarray

Given a array ‘a[]’ of size n and number of queries q. Each query can be represented by two integers l and r. Your task… Read More »

## Number of elements less than or equal to a given number in a given subarray

Given an array ‘a[]’ and number of queries q. Each query can be represented by l, r, x. Your task is to print the number… Read More »

## Count inversion pairs in a matrix

Given a matrix A of size NxN, we need to find the number of inversion pairs in it. Inversion count in a matrix is defined… Read More »

## proto van Emde Boas Trees | Set 1 (Background and Introduction)

Let us consider the below problem statement and think of different solutions for it. Given a set S of elements such that the elements are… Read More »

## Binary Indexed Tree : Range Update and Range Queries

Given an array arr[0..n-1]. The following operations need to be performed. update(l, r, val) : Add ‘val’ to all the elements in the array from… Read More »

## How to prepare for ACM – ICPC?

ACM ICPC(Association for Computing Machinery – International Collegiate Programming Contest) is a world-wide annual multi-tiered programming contest being organized for over thirteen years. The contest… Read More »

## Binary Indexed Tree : Range Updates and Point Queries

Given an array arr[0..n-1]. The following operations need to be performed. update(l, r, val) : Add ‘val’ to all the elements in the array from… Read More »

## Finding the number of triangles amongst horizontal and vertical line segments

Prerequisites: BIT Given ‘n’ line segments, each of them is either horizontal or vertical, find the maximum number of triangles(including triangles with zero area) that… Read More »