## Number of handshakes such that a person shakes hands only once

There are N number of persons in a party, find the total number of handshake such that a person can handshake only once. Examples: Input… Read More »

## Count pairs with Bitwise AND as ODD number

Given an array of N integers. The task is to find the number of pairs (i, j) such that A[i] & A[j] is odd. Examples:… Read More »

## Number of ways to reach Nth floor by taking at-most K leaps

Given N number of stairs. Also given the number of steps that one can cover at most in one leap (K). The task is to… Read More »

## Count unique subsequences of length K

Given an array of N numbers and an integer K. The task is to print the number of unique subsequences possible of length K. Examples:… Read More »

## Count number of triplets with product equal to given number with duplicates allowed | Set-2

Given an array of positive integers(may contain duplicates) and a number ‘m’, find the number of unordered triplets ((Ai, Aj, Ak) and (Aj, Ai, Ak)… Read More »

## Probability that the pieces of a broken stick form a n sided polygon

We have a stick of length L. The stick got broken at (n-1) randomly chosen points (lengths of parts can be non-integer or floating point… Read More »

## Dilworth’s Theorem

Let S be a finite partially ordered set. The size of a maximal antichain equals the size of a minimal chain cover of S. This… Read More »

## Print all the combinations of N elements by changing sign such that their sum is divisible by M

Given an array of N integers and an integer M. You can change the sign(positive or negative) of any element in the array. The task… Read More »

## Number of ways to form an array with distinct adjacent elements

Given three integers N, M and X, the task is to find the number of ways to form an array, such that all consecutive numbers… Read More »

## Minimum number of operations to convert a given sequence into a Geometric Progression

Given a sequence of N elements, only three operations can be performed on any element at most one time. The operations are: Add one to… Read More »

## Number of permutations such that sum of elements at odd index and even index are equal

Given N numbers, find the number of permutations in which the sum of elements at odd index and sum of elements at even index are… Read More »

## Different ways to represent N as sum of K non-zero integers

Given N and K. The task is to find out how many different ways are there to represent N as the sum of K non-zero… Read More »

## Check if a binary string contains all permutations of length k

Given a binary string and k, to check whether it’s contains all permutations of length k or not. Examples: Input : Binary string 11001 k… Read More »

## Number of arrays of size N whose elements are positive integers and sum is K

Given two positive integers N and K. The task is to find the number of arrays of size N that can be formed such that… Read More »