# Tag Archives: Segment-Tree

## Queries for the count of even digit sum elements in the given range using Segment Tree.

Given an array arr[] of N elements, the task is to answer Q queries each having two integers L and R. For each query, the… Read More »

## Range Queries to find the Element having Maximum Digit Sum

Given an array Arr of N integers and Q queries, each query having a range from L to R. Find the element having maximum digit… Read More »

## Range Update Queries to XOR with 1 in a Binary Array.

Given a binary array arr[] of size N. The task is to answer Q queries which can be of any one type from below: Type… Read More »

## Queries for elements having values within the range A to B in the given index range using Segment Tree

Given an array arr[] of N elements and two integers A to B, the task is to answer Q queries each having two integers L… Read More »

## Array range queries to count the number of Fibonacci numbers with updates

Given an array arr[] of N integers, the task is to perform the following two queries: query(start, end): Print the number of fibonacci numbers in… Read More »

## Count of divisors of product of an Array in range L to R for Q queries

Given an array arr of size N and Q queries of the form [L, R], the task is to find the number of divisors of… Read More »

## Dynamic Segment Trees : Online Queries for Range Sum with Point Updates

Prerequisites: Segment Tree Given a number N which represents the size of the array initialized to 0 and Q queries to process where there are… Read More »

## Binary Array Range Queries to find the minimum distance between two Zeros

Prerequisite: Segment Trees Given a binary array arr[] consisting of only 0’s and 1’s and a 2D array Q[][] consisting of K queries, the task… Read More »

## Maximum pair sum in the given index ranges of an Array

Given an array arr containing N positive integers and the number of queries Q, for each query task is to find the maximum pair sum… Read More »

## Maximum distance between two 1s in a Binary Array in a given range

Given a binary array of size N and a range in [l, r], the task is to find the maximum distance between two 1s in… Read More »

## Range Sum and Update in Array : Segment Tree using Stack

Given an array arr[] of N integers. The task is to do the following operations: Add a value X to all the element from from… Read More »

## Build a segment tree for N-ary rooted tree

Prerequisite: Segment tree and depth first search. In this article, an approach to convert an N-ary rooted tree( a tree with more than 2 children)… Read More »

## Length of Longest Subarray with same elements in atmost K increments

Given an integer array arr and a number K, the task is to find the length of longest subarray such that all the elements in… Read More »

## Query to check if a range is made up of consecutive elements

Given an array of n non-consecutive integers and Q queries, the task is to check whether for the given range l and r, the elements… Read More »

## Count number of increasing sub-sequences : O(NlogN)

Given an array arr[] of length N, the task is to find the number of strictly increasing sub-sequences in the given array. Examples: Input: arr[]… Read More »
{"ft_lang_label":"__label__en","ft_lang_prob":0.7972654,"math_prob":0.89329565,"size":2351,"snap":"2020-34-2020-40","text_gpt3_token_len":567,"char_repetition_ratio":0.21048146,"word_repetition_ratio":0.26086956,"special_character_ratio":0.24330072,"punctuation_ratio":0.073469386,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97260123,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-10T19:05:05Z\",\"WARC-Record-ID\":\"<urn:uuid:ad87ffb4-f7ea-44d0-ae34-634bf02f24f7>\",\"Content-Length\":\"119282\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f10a258b-a199-449d-8707-fd23fc6d6c99>\",\"WARC-Concurrent-To\":\"<urn:uuid:c1a741fb-4cab-4365-afbd-cfc79f9ed712>\",\"WARC-IP-Address\":\"23.199.71.163\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/tag/segment-tree/page/2/\",\"WARC-Payload-Digest\":\"sha1:RSEZA66KUORZXRP2NHYGRWG3DS7NQ5JR\",\"WARC-Block-Digest\":\"sha1:IF4D7TUT3BV2LO6E7JW63ATYD643TRLE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439737168.97_warc_CC-MAIN-20200810175614-20200810205614-00206.warc.gz\"}"}