# Category Archives: Combinatorial

## Count substring of Binary string such that each character belongs to a palindrome of size greater than 1

Given a binary string str, the task is to count the number of substrings of the given string str such that each character of the… Read More »

## Permutation of Array such that sum of adjacent elements are not divisible by 3

Given an array arr[] of positive integers, the task is to find the permutation of the array such that sum of adjacent elements is not… Read More »

## Maximum profit such that total stolen value is less than K to get bonus

Given an integer K and an array arr[] which denotes the amount that can be stolen, the task is to choose a subset of items… Read More »

## Count of unique palindromic strings of length X from given string

Given a string s and an integer X, our task is to find the number of distinct palindromic strings of length X from the given… Read More »

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