## Minimum Cost Graph

Given N nodes on a 2-D plane represented as (xi, yi). The nodes are said to be connected if the manhattan distance between them is… Read More »

## Count of different groups using Graph

Given a graph with N nodes having values either P or M. Also given K pairs of integers as (x, y) representing the edges in… 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 »

## Octree | Insertion and Searching

Octree is a tree data structure in which each internal node can have at most 8 children. Like Binary tree which divides the space two… Read More »

## Perform append, update, delete and range sum queries on the given array

Given an array arr[] of size N and the task is to answer Q queries of the following types: 1 X 0: Append X at… Read More »

## Longest subsequence having difference atmost K

Given a string S of length N and an integer K, the task is to find the length of longest sub-sequence such that the difference… Read More »

## Kth ancestor of a node in an N-ary tree using Binary Lifting Technique

Given a vertex V of an N-ary tree and an integer K, the task is to print the Kth ancestor of the given vertex in… Read More »

## Queries for elements greater than K in the given index range using Segment Tree

Given an array arr[] of N elements and a number of queries where each query will contain three integers L, R and K. For each… Read More »

## Cyclic Iterator for K variable length vectors

Given K vectors, the task is to design a cyclic iterator that prints the elements of these vectors in a cyclic manner. For example: v1… Read More »

## Find the maximum amount that can be collected by selling movie tickets

Given an integer N and an array seats[] where N is the number of people standing in a line to buy a movie ticket and… Read More »

## Calculate the Sum of GCD over all subarrays

Given an array of integers, the task is to calculate the sum of GCD of all the subarrays of an array. GCD of an array… Read More »

## Multiplication on Array : Range update query in O(1)

Consider an array A[] of integers and the following two types of queries. update(l, r, x): multiply x to all values from A[l] to A[r]… Read More »

## Number of subarrays with GCD = 1 | Segment tree

Given an array arr[], the task is to find the count of sub-arrays with GCD equal to 1. Examples: Input: arr[] = {1, 1, 1}… Read More »

## Smallest subarray with GCD as 1 | Segment Tree

Given an array arr[], the task is to find the smallest sub-arrays with GCD equal to 1. If there is no such sub-array then print… Read More »

## Range maximum query using Sparse Table

Given an array arr[], the task is to answer queries to find the maximum of all the elements in the index range arr[L…R]. Examples: Input:… Read More »