Skip to content

Tag Archives: array-range-queries

Given an array arr[0 . . . n-1]. We need to efficiently find the minimum and maximum value from index qs (query start) to qe… Read More
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
Given an array of integers, evaluate queries of the form LCM(l, r). There might be many queries, hence evaluate the queries efficiently.  LCM (l, r)… Read More
Prerequisites :  Suffix Array | Set 2 kasai’s algorithm The Longest Common Extension (LCE) problem considers a string s and computes, for each pair (L… Read More
Prerequisite – Fenwick TreeWe know that to answer range sum queries on a 1-D array efficiently, binary indexed tree (or Fenwick Tree) is the best… Read More
Given an empty set initially and a number of queries on it, each possibly of the following types:   Insert – Insert a new element ‘x’.… Read More
Given an array a[0 . . . n-1]. We should be able to efficiently find the GCD from index qs (query start) to qe (query… Read More
We strongly recommend to refer below post as a prerequisite of this.Heavy Light Decomposition | Set 1 (Introduction)In the above post, we discussed the Heavy-light… Read More
Heavy Light decomposition (HLD) is one of the most used techniques in competitive programming. Example Problem: Let us understand Heavy-light decomposition (HLD) with the help… Read More
We have an array arr[0 . . . n-1]. We should be able to efficiently find the minimum value from index L (query start) to… Read More
Let us consider the following problem to understand MO’s Algorithm.We are given an array and a set of query ranges, we are required to find… Read More
Segment tree is introduced in previous post with an example of range sum problem. We have used the same “Sum of given Range” problem to… Read More
Let us consider the following problem to understand Binary Indexed Tree.We have an array arr[0 . . . n-1]. We would like to 1 Compute the… Read More
We have introduced segment tree with a simple example in the previous post. In this post, Range Minimum Query problem is discussed as another example… Read More
Let us consider the following problem to understand Segment Trees.We have an array arr[0 . . . n-1]. We should be able to  Find the… Read More

Start Your Coding Journey Now!