# Category Archives: Combinatorial

## Count of ways to generate a Matrix with product of each row and column as 1 or -1

Given two integers N and M, the task is to find the numbers of ways to form a matrix of size N * M consisting… Read More »

## Count of N-digit numbers with absolute difference of adjacent digits not exceeding K

Given two integers N and K, the task is to find the count of N-digit numbers such that the absolute difference of adjacent digits in… Read More »

## Select K elements from an array whose maximum value is minimized

Given an array arr[] having N integers and an integer K, the task is to select K elements from the given array such that sum… Read More »

## Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s

Given two integers N and K, the task is to count the numbers up to N digits such that no two zeros are adjacents and… Read More »

## Count of substrings formed using a given set of characters only

Given a string str and an array arr[] of K characters, the task is to find the number of substrings of str that contains characters… Read More »

## Maximum sum by picking elements from two arrays in order | Set 2

Given two arrays A[] and B[], each of size N, and two integers X and Y denoting the maximum number of elements that can be… Read More »

## Count sequences of length K having each term divisible by its preceding term

Given two integer N and K, the task is to find the number of sequence of length K consisting of values from the range [1,… Read More »

## Count of binary strings of given length consisting of at least one 1

Given an integer N, the task is to print the number of binary strings of length N which at least one ‘1’. Examples: Input: 2… Read More »

## Count of groups among N people having only one leader in each group

Given N number of people, the task is to count the number of ways to form groups of size ≤ N where, in each group,… Read More »

## Count of ways to distribute N items among 3 people with one person receiving maximum

Given an integer N, the task is to find the total number of ways to distribute N among 3 people such that: Exactly one person… Read More »

## Check if all objects of type A and B can be placed on N shelves

Given two integers A and B, representing the count of objects of two different types, and another integer N which represents the number of shelves,… Read More »

## Find all possible ways to Split the given string into Primes

Given a string str that represents a number. The task is to find all possible ways to split the given string such that each segment… Read More »

## Sum of sum-series of first N Natural numbers

Given a natural number n, find the sum of sum-series of first N natural number. Sum-Series: is sum of first N natural numbers, i.e, sum-series… Read More »

## Number of ways to reach (M, N) in a matrix starting from the origin without visiting (X, Y)

Given four positive integers M, N, X, and Y, the task is to count all the possible ways to reach from top left(i.e., (0, 0))… Read More »

## Largest possible square submatrix with maximum AND value

Given an integer matrix mat [ ][ ] dimensions, the task is to find the largest possible square matrix from the given matrix with maximum… Read More »