## Lowest Common Ancestor in Parent Array Representation

Given a binary tree represented as parent array, find Lowest Common Ancestor between two nodes ‘m’ and ‘n’. In the above diagram, LCA of 10… Read More »

Given a binary tree represented as parent array, find Lowest Common Ancestor between two nodes ‘m’ and ‘n’. In the above diagram, LCA of 10… Read More »

Given two numbers A and B where 1 <= A <= B. The task is to count the number of pairs whose elements are co-prime… Read More »

Given an array A[] and size of array is N. The task is to delete element of array A[] are in given range L to… Read More »

Given an undirected weighted graph. The task is to find the minimum cost of the path from source node to the destination node via an… Read More »

Given an array of N numbers and an integer K. The task is to print the number of unique subsequences possible of length K. Examples:… Read More »

Given an array of integers and an integer x. Find length of maximum size subarray having average of integers greater than or equal to x.… Read More »

Given a graph, the task is to print the DFS traversal of a graph which includes the every step including the backtracking. 1st step:- 0… Read More »

Prerequisites : std::sort in C++, vector in C++, initialize a vector in C++. // C++ program to sort a vector in non-decreasing // order. #include… Read More »

A Vectors in C++ can resize itself when more elements are added. It also allows deletion of elements. A basic idea is to double the… Read More »

Given a connected graph, check if the graph is bipartite or not. A bipartite graph is possible if the graph coloring is possible using two… Read More »

Given lengths of n rods in an array a[]. If any person picks any rod, half of the longest rod (or (max + 1) /… Read More »

Generate all prime numbers between two given numbers. The task is to print prime numbers in that range. The Sieve of Eratosthenes is one of… Read More »

Given k sorted arrays of possibly different sizes, merge them and print the sorted output. Examples: Input: k = 3 arr[][] = { {1, 3},… Read More »

std::vector::insert() is a built-in function in C++ STL which inserts new elements before the element at the specified position, effectively increasing the container size by… Read More »

The vector::capacity() function is a built-in function which returns the size of the storage space currently allocated for the vector, expressed in terms of elements.… Read More »