# Category Archives: Competitive Programming

## Octal equivalents of connected components in Binary valued graph

Given a binary valued undirected graph with V vertices and E edges, the task is to find the octal equivalents of all the connected components… Read More »

## Count of ways to represent N as sum of a prime number and twice of a square

Given an integer N, the task is to count the number of ways so that N can be written as the sum of a prime… Read More »

## Minimum difference between any two weighted nodes in Sum Tree of the given Tree

Given a tree of N nodes, the task is to convert the given tree to its Sum Tree(including its own weight) and find the minimum… Read More »

## Count number of triangles possible for the given sides range

Given four integers A, B, C, and D, the task is to find the number of distinct sets (X, Y, and Z) where X, Y… Read More »

## Count of index pairs in array whose range product is a positive integer

Given an array A of non-zero integers, the task is to find the number of pairs (l, r) where (l <= r) such that A[l]*A[l+1]*A[l+2]….A[r]… Read More »

## Count numbers in a range with digit sum divisible by K having first and last digit different

Given a range in the form of L and R, and a value K, the task is to count the numbers between the range L… Read More »

## Queries for count of even digit sum elements in given range using MO’s Algorithm

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 »

## Find distance between two nodes in the given Binary tree for Q queries

Given a binary tree having N nodes and weight of N-1 edges. The distance between two nodes is the sum of the weight of edges… Read More »

## XOR of elements in a given range with updates using Fenwick Tree

Given an array A[] of integers and array Q consisting of queries of the following two types: (1, L, R) : Return XOR of all… Read More »

## Count of nodes having odd divisors in the given subtree for Q queries

Given a N-ary Tree and Q queries where each query contains a node of the N-ary tree, the task is to count the number of… Read More »

## Query to count odd and even parity elements in subarray after XOR with K

Given an array arr[] consisting of N elements and Q queries represented by L, R, and K. The task is to print the count of… Read More »

## Maximum weighted edge in path between two nodes in an N-ary tree using binary lifting

Given an N-ary tree with weighted edge and Q queries where each query contains two nodes of the tree. The task is to find the… Read More »

## Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings

Given a numeric string target of length N and a set of numeric strings blocked, each of length N, the task is to find the… Read More »

## Split a binary string into K subsets minimizing sum of products of occurrences of 0 and 1

Given a binary string S, the task is to partition the sequence into K non-empty subsets such that the sum of products of occurences of… Read More »

## Binary string with given frequencies of sums of consecutive pairs of characters

Given three integers P, Q, and R, the task is to generate a binary string with P, Q, and R pairs of consecutive characters with… Read More »