Skip to content

Category Archives: Advanced Data Structure

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
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
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 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
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
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
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
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
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
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
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
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
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} Output: 6 Every… Read More
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
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: arr[]… Read More