# Category Archives: Competitive Programming

## Count of subsets of integers from 1 to N having no adjacent elements

Given an integer N, the task is to count the number of subsets formed from an array of integers from 1 to N which doesn’t… Read More »

## Count the number of ordered sets not containing consecutive numbers

Given a positive integer N. Count the total number of ordered sets of any size such that consecutive numbers are not present in the set… Read More »

## Maximum LCM among all pairs (i, j) from the given Array

Given an array arr[], the task is to find the maximum LCM when the elements of the array are taken in pairs. Examples: Input: arr[]… Read More »

## Dividing Sticks Problem

Given a list of integer each representing the length of each stick and an integer which tells how many times we can break a stick… Read More »

## How to become a 4 star coder on codechef in only 3 contests ?

Many people messaged me how you achieved 4 stars in only 3 contests in a month interval.That sounds amazing! But the reality is I am… Read More »

## Count of distinct characters in a substring by given range for Q queries

Given a string S consisting of lower case alphabets of size N and Q queries in the range [L, R], the task is to print… Read More »

## Lexicographically all Shortest Palindromic Substrings from a given string

Given a string s of size N. The task is to find lexicographically all shortest palindromic substrings from the given string. Examples: Input: s= “programming”… Read More »

## Minimize bits to be flipped in X and Y such that their Bitwise OR is equal to Z

Given three positive integers X, Y and Z, the task is to count the minimum numbers of bits required to be flipped in X and… Read More »

## Setting up a C++ Competitive Programming Environment

In this article we will learn about how to setup a all in one Competitive Programming Environment Operating System It is always recommended to use… Read More »

## Find all divisors of N2 using N

Given a number N, the task is to print all distinct divisors of N2. Examples: Input: N = 4 Output: 1 2 4 8 16… Read More »

## Queries for Count of divisors of product of an Array in given range | Set 2 (MO’s Algorithm)

Given an array arr of size N and Q queries of the form [L, R], the task is to find the number of divisors of… Read More »

## Queries for the count of even digit sum elements in the given range using Segment Tree.

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 sum of xor of all unordered triplets of the array

Given an array A, consisting of N non-negative integers, find the sum of xor of all unordered triplets of the array. For unordered triplets, the… Read More »

## Move all zeroes to end of array using Two-Pointers

Given an array of random numbers, Push all the zero’s of the given array to the end of the array. For example, if the given… Read More »

## Count of numbers in a range that does not contain the digit M and which is divisible by M.

Given three integers the lower range L ,the upper range U and a digit M. The task is to count all the numbers between L… Read More »