# Category Archives: Competitive Programming

## Maximum sum of values of nodes among all connected components of an undirected graph

Given an undirected graph with V vertices and E edges. Every node has been assigned a given value. The task is to find the connected… Read More »

## Sum of all parts of a square Matrix divided by its diagonals

Given a 2D matrix arr[][] of N*N dimensions, the task is to find the sum of elements of all four parts of the matrix divided… Read More »

## Find the value mapped to a given composite key for every query

Given three arrays firstkey[], secondkey[] and value[] where elements firstkey[i] and secondkey[i] denotes a composite key and their value is value[i], the task is to… Read More »

## Length of Longest Perfect number Subsequence in an Array

Given an array arr[] containing non-negative integers of length N, the task is to print the length of the longest subsequence of Perfect numbers in… Read More »

## Find the length of largest subarray in which all elements are Autobiographical Numbers

Given an array arr[] of integers, our task is to find the length of the largest subarray such that all the elements of the sub-array… Read More »

## Difference Between sum of degrees of odd and even degree nodes in an Undirected Graph

Given an undirected graph with N vertices and M edges, the task is to find the absolute difference Between sum of degrees of odd degree… Read More »

## Number of shuffles required for each element to return to its initial position

Given an integer array arr[] containing a permutation of integers from 1 to N. Let K[] be some arbitrary array. Every element in the array… Read More »

## Find the maximum component size after addition of each edge to the graph

Given an array arr[][] which contains the edges of a graph to be used to construct an undirected graph G with N nodes, the task… Read More »

## Sum of product of all subsets formed by only divisors of N

Given a number N, the task is to find the sum of the product of elements of all the possible subsets formed by only divisors… Read More »

## Append the elements of queue in mirror-inverse order

Given a queue Q containing N strings, the task is to restructure the queue to double its size such that the second half represents the… Read More »

## Balance the parentheses for the given number N

Given a number N, the task is to insert the minimum number of opening and closing parenthesis into the number N such that the resultant… Read More »

## Length of longest Powerful number subsequence in an Array

Given an array arr[] containing non-negative integers of length N, the task is to print the length of the longest subsequence of Powerful numbers in… Read More »

## Find the XOR of the elements in the given range [L, R] with the value K for a given set of queries

Given an array arr[] and Q queries, the task is to find the resulting updated array after Q queries. There are two types of queries… Read More »

## Score of Parentheses using Tree

Given a string str which contains pairs of balanced parentheses, the task is to calculate the score of the given string based on the given… Read More »

## Count the numbers which can convert N to 1 using given operation

Given a positive integer N (N ≥ 2), the task is to count the number of integers X in the range [2, N] such that… Read More »