Skip to content

Tag Archives: Segment-Tree

Given an array arr[] of size N where each element denotes a pair in the form (price, weight) denoting the price and weight of each… Read More
Given an array arr, the task is to replace each array element by the maximum of K next and K previous elements. Example: Input: arr[]… 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
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
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
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
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
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
Given an array arr[] of size N, the task is to count the number of longest increasing subsequences present in the given array. Example: Input:… Read More
Given an array arr[] of N integers, an integer K, and Q queries of the type as explained below: (1, L, R): If the query… Read More
Given an array arr[] consisting of N integers, the task is to find the maximum length of subarray having the Greatest Common Divisor (GCD) of… Read More
Given a string S of size N consisting of characters a, b, and c only, the task is to find the number of substrings of… Read More
Given an array arr[] consisting of N positive integers and an array Query[][2] consisting of Q queries of the form {L, R}, the task is… Read More
Given a string S of length N and a 2D array of strings Q[][] consisting of M queries of the following type: Query(“U”, “I”, “X”):… Read More
Given an Array arr[] of positive integers of size n. We are required to perform following 3 queries on given array – 1) Given L… Read More

Start Your Coding Journey Now!