# Category Archives: Competitive Programming

## Print all distinct Coprime sets possible from 1 to N

Given an integer N, the task is to find all distinct co-prime sets up to the given integer N such that an element doesn’t appear… Read More »

## Check if a matrix contains a square submatrix with 0 as boundary element

Given an N*N binary matrix arr[][], the task is to check if the matrix contains a square of at least size 2 x 2 whose… Read More »

## Find the sequence number of a triangular number

Given an integer N print the sequence number of the given Triangular Number. If the number is not a triangular number then print -1. A… Read More »

## Queries to find frequencies of a string within specified substrings

Given a string S and a matrix Q of queries, each specifying the starting and ending indices L( = Q[i][0]) and R( = Q[i][0]) respectively… Read More »

## Maximum decimal equivalent possible among all connected components of a Binary Valued Graph

Given a binary valued Undirected Graph with V vertices and E edges, the task is to find the maximum decimal equivalent among all the connected… Read More »

## Minimum flips required to generate continuous substrings of 0’s and 1’s

Given a binary string S of length N, the task is to find the minimum number of bit flips required to convert the given string… Read More »

## Maximum subsequence sum of at most K-distant adjacent elements

Given an array arr[] consisting of integers of length N and an integer K (1 <= K <= N), the task is to find the… Read More »

## Count of subarrays of size K which is a permutation of numbers from 1 to K

Given an array arr of distinct integers, the task is to find count of sub-arrays of size i having all elements from 1 to i,… Read More »

## Check if a given string can be formed using characters of adjacent cells of a Matrix

Given a matrix board of characters and a string Word, the task is to check if Word exists on the board constructed from a sequence… Read More »

## Split the number N by maximizing the count of subparts divisible by K

Given a numeric string N and an integer K, the task is to split digits of N into subparts such that the number of segments… Read More »

## Count of distinct possible strings after performing given operations

Given a numeric string S consisting of only three types of characters 0, 1 and 2 initially and following two operations: Occurrence of two consecutive… Read More »

## Count subarrays with sum equal to its XOR value

Given an array arr[] containing N elements, the task is to count the number of sub-arrays whose XOR of all the elements is equal to… Read More »

## Count of subarrays which contains a given number exactly K times

Given an array A[] of N elements consisting of values from 1 to N with duplicates, the task is to find the total number of… Read More »

## Count of pairs in an Array whose sum is Prime

Given an array arr of size N elements, the task is to count the number of pairs of elements in the array whose sum is… Read More »

## Minimum side of square embedded in Regular polygon with N sides

Given an even number N which represents the number of sides of a regular polygon with N vertices, the task is to find the square… Read More »