Given an array A[], for each element in the array, the task is to find the sum of all the previous elements which are strictly… Read More

# Tag Archives: Binary Indexed Tree

Given an array A[] of integers and array Q consisting of queries of the following two types: (1, L, R) : Return XOR of all… Read More

Given a rooted tree (assume root is 1) of N nodes and Q queries, each of the form (Val, Node). For each query, the task… Read More

Given an array arr[] of size N. The task is to find smaller elements on the right side and greater elements on the left side… Read More

Given a tree of N nodes and an integer K, each node is numbered between 1 and N. The task is to find the number… Read More

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

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

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

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

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

Given an array of size n. Find the maximum sum of an increasing subsequence.Examples: Input : arr[] = { 1, 20, 4, 2, 5 }… Read More

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

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

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

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