# Category Archives: Competitive Programming

## Game Theory in Balanced Ternary Numeral System | (Moving 3k steps at a time)

Just like base 2 Binary numeral system having 0s and 1s as digits, Ternary(Trinary) Numeral System is a base 3 number system having 0s, 1s… Read More »

## Highest power of 2 that divides a number represented in binary

Given a binary string str, the task is to find the largest power of 2 that divides the decimal equivalent of the given binary number.… Read More »

## Number of ways to arrange K different objects taking N objects at a time

Given two integers K and N, the task is to count the number of ways to arrange K different objects taking N objects at a… Read More »

## Find the minimum sum of distance to A and B from any integer point in a ring of size N

Given a circular ring which has marking from 1 to N. Given two numbers A and B, you can stand at any place(say X) and… Read More »

## Check if a number from every row can be selected such that xor of the numbers is greater than zero

Given a 2-D array of order N X M array elements, the task is to check if we can select a number from every row… Read More »

## Find the original matrix when largest element in a row and a column are given

Given two arrays A[] and B[] of N and M integers respectively. Also given is a N X M binary matrix where 1 indicates that… Read More »

## Find the maximum possible value of a[i] % a[j] over all pairs of i and j

Given an array arr[] of N positive integers. The task is to find the maximum possible value of a[i] % a[j] over all pairs of… Read More »

## Find the number of divisors of all numbers in the range [1, n]

Given an integer N. The task is to find the number of divisors of all the numbers in the range [1, N]. Examples: Input: N… Read More »

## Find the number of sub arrays in the permutation of first N natural numbers such that their median is M

Given an array arr[] containing the permutation of first N natural numbers and an integer M ≤ N. The task is to find the number… Read More »

## Program to find the maximum difference between the index of any two different numbers

Given an array of N integers. The task is to find the maximum difference between the index of any two different numbers. Note that there… Read More »

## Interactive Problems in Competitive Programming

Interactive Problems are those problems in which our solution or code interacts with the judge in real time. When we develop a solution for an… Read More »

## Find the minimum number of operations required to make all array elements equal

Given an array arr[] of size N. The task is to make all the array elements equal by applying the below operations minimum number of… Read More »

## Convert the undirected graph into directed graph such that there is no path of length greater than 1

Given an undirected graph with N vertices and M edges and no self loops or multiple edges. The task is to convert the given undirected… Read More »

## Lazy Propagation in Segment Tree | Set 2

Given an array arr[] of size N. There are two types of operations: Update(l, r, x) : Increment the a[i] (l <= i <= r)… Read More »

## Find n positive integers that satisfy the given equations

Given three integers N, X and Y. The task is to find N positive integers that satisfy the given equations. a12 + a22 + ….… Read More »