##
LIS using Segment Tree
October 21, 2017

You are given an array of integers, you need to find the length of the longest increasing sub-sequence. There can be 4 approaches for solving… Read More »

October 21, 2017

You are given an array of integers, you need to find the length of the longest increasing sub-sequence. There can be 4 approaches for solving… Read More »

October 19, 2017

Let us consider the following problem to understand Segment Trees without recursion. We have an array arr[0 . . . n-1]. We should be able… Read More »

October 7, 2017

Given an array of n integers and q queries, each query having a range from l to r. Find the maximum prefix-sum for the range… Read More »

June 14, 2017

We have an array arr[0 . . . n-1]. There are two type of queries Find the XOR of elements from index l to r… Read More »

Given an array where each element is a vector containing integers in sorted order. The task is to answer following queries: count(start, end, k) :… Read More »

May 28, 2017

We are given 2*N – 1 integers. We need to check whether it is possible to construct a Range Minimum Query segment tree for an… Read More »

February 10, 2017

Prerequisite : Segment Tree Persistency in Data Structure Segment Tree is itself a great data structure that comes into play in many cases. In this… Read More »

November 4, 2016

Given Q queries, of type: L R, for each query you must print the maximum number of divisors that a number x (L <= x… Read More »

October 4, 2016

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 »

October 1, 2016

Given a size n in which initially all elements are 0. The task is to perform multiple multiple queries of following two types. The queries… Read More »

September 11, 2016

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 »

July 26, 2016

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 »

July 24, 2016

Prerequisites : LCE(Set 1), LCE(Set 2), Suffix Array (n Log Log n), Kasai’s algorithm and Segment Tree The Longest Common Extension (LCE) problem considers a… Read More »

July 1, 2016

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 »

June 13, 2016

Given an array arr[] of n numbers and an integer k, find length of the minimum sub-array with gcd equals to k. Example: Input: arr[]… Read More »