# Category Archives: Competitive Programming

## Largest subarray sum of all connected components in undirected graph

Given an undirected graph with V vertices and E edges, the task is to find the maximum contiguous subarray sum among all the connected components… Read More »

## Longest subarray such that difference of max and min is at-most K

Given an array arr[] of length N, tark is to find the length of longest subarray such that difference of its maximum element and minumum… Read More »

## Number formed by adding product of its max and min digit K times

Given two integers N and K, the task is to print the number formed by adding product of its max and min digit, K times.… Read More »

## Find K-th smallest element in an array for multiple queries

Given an array arr[] of size N and an array Q[][] consisting of M queries that needs to be processed on the given array. It… Read More »

## Count of elements which form a loop in an Array according to given constraints

Given an array A containing N integers, the task is to count the number of elements which form a cycle in the array, based on… Read More »

## Count of operations to make all elements of array a[] equal to its min element by performing a[i] – b[i]

Given two array a[] and b[] of size N, the task is to print the count of operations required to make all the elements of… Read More »

## Find the Nth natural number which is not divisible by A

Given two integers A and N, our task is to find the Nth natural number which is not divisible by A. Examples: Input: A =… Read More »

## Logarithm tricks for Competitive Programming

Logarithm: is the inverse function of the exponentiation which means the logarithm value of a given number x is the exponent to another number. Below… Read More »

## Find the maximum Even Digit Sum node in the given tree

Given a tree with the weights of all the nodes, the task is to find the maximum weighing node whose weight has even digit sum.… Read More »

## Count of Nodes which has Prime Digit sum weight in a Tree

Given a weighted tree, the task is to count the number of nodes whose sum of digits of weights is a Prime Number. Examples: Input:… Read More »

## Count the number of Prime Cliques in an undirected graph

Given a graph with N nodes and E edges, the task is to count the number of clique having their size as a prime number… Read More »

## Length of longest increasing index dividing subsequence

Given an array arr[] of size N, the task is to find the longest increasing sub-sequence such that index of any element is divisible by… Read More »

## Count of subarrays which start and end with the same element

Given an array A of size N where the array elements contain values from 1 to N with duplicates, the task is to find total… Read More »

## Range Queries for finding the Sum of all even parity numbers

Given Q queries where each query consists of two numbers L and R which denotes a range [L, R]. The task is to find the… Read More »

## Range Queries for number of Armstrong numbers in an array 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 Armstrong numbers in… Read More »