# Category Archives: Combinatorial

## 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 »

## Permutation of first N positive integers such that prime numbers are at prime indices | Set 2

Given an integer N, the task is to find the number of permutations of first N positive integers such that prime numbers are at prime… Read More »

## Count the number of ways to fill K boxes with N distinct items

Given two values N and K. Find the number of ways to arrange the N distinct items in the boxes such that exactly K (K<N)… Read More »

## Probability of getting K heads in N coin tosses

Given two integers N and R. The task is to calculate the probability of getting exactly r heads in n successive tosses. A fair coin… 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 »

## Number of ways to arrange N numbers which are in a range from 1 to K under given constraints.

Given Four integers N, K, P and Q. The task is to calculate the number of ways to arrange N numbers which are in a… Read More »

## Count rotations which are divisible by 10

Given a number N, the task is to count all the rotations of the given number which are divisible by 10. Examples: Input: N =… Read More »

## Number of subsets with same AND, OR and XOR values in an Array

Given an array arr[] of size N consisting of non-negative integers, the task is to find the number of non-empty subsets of the array such… Read More »

## Longest permutation subsequence in a given array

Given an array arr containing N elements, find the length of the longest subsequence such that it is a valid permutation of a particular length.… Read More »

## Sum of GCD of all possible sequences

Given two numbers N and K. A sequence A1, A2, ….AN of length N can be created by placing numbers from 1 to K at… Read More »

## Find the Number of Permutations that satisfy the given condition in an array

Given an array arr[] of size N, the task is to find the number of permutations in the array that follows the given condition: If… Read More »

## Print the two possible permutations from a given sequence

Given an array arr containing N positive integers, the task is to check if the given array can be dissociated into two permutations or not… Read More »

## Find number of ways to form sets from N distinct things with no set of size A or B

Given three numbers N, A, B. The task is to count the number of ways to select things such that there exists no set of… Read More »

## Number of pairs such that path between pairs has the two vertices A and B

Given an undirected connected graph and two vertices A and B, the task is to find the number of pairs of vertices {X, Y} such… Read More »

## Count the numbers with N digits and whose suffix is divisible by K

Given two positive integers N and K, the task is to count the number of positive integers D such that D has N digits and… Read More »