Skip to content

Category Archives: Combinatorial

Given an array A[] of size N, the task is to count the number of subsequences from the given array whose Bitwise XOR value is… Read More
Given an array arr[] of size N, representing the number of balls of each of N distinct colors, the task is to find the probability… Read More
Given an integer N and two integers D1 and D2 ( < 10), the task is to find the number of co-prime pairs less than… Read More
Given an array arr[] consisting of N integers, the task is to find the remaining array element after subtracting each element from its next adjacent… Read More
Given a string S of length N, the task is to count the number of anagrams of S whose first character is a consonant and… Read More
Given a positive integer N, the task is to find the number of binary strings of length N which contains “11” as a substring. Examples:… Read More
Given an array nums[] of size N, the task is to print all possible distinct permutations of the array nums[] (including duplicates). Input: nums[] =… Read More
Given an array arr[] of size N, the task is to find the maximum and minimum sum of Bitwise XOR of all pairs from an… Read More
Given an array arr[] consisting of N integers and an integer K, the task is to find the number of ways to split the array… Read More
Given a binary string S of length N, the task is to find the lexicographic rank of the given string. Examples: Input: S = “001”Output:… Read More
Given an array arr[] consisting of N integers, the task is to count the number of ways to make the product of array elements even… Read More
Given two positive integers N and M, the task is to find the number of ways to place M distinct objects in partitions of even… Read More
Cayley’s Formula: This formula tells how many trees can be constructed with N vertices. It states that there are NN – 2  labeled trees that… Read More
Given an integer N, the task is to count the number of ways to represent N as the sum of powers of 2. Examples: Input:… Read More