Tag Archives: Pigeonhole Principle

Construct a string that contains a times letter ‘A’ and b times letter ‘B’ (a > b) such that the maximum continuous occurrence of a… Read More
Given two integers A and B, the task is to find a triplet (X, Y, Z) such that all of them are divisible by A,… Read More
Given three binary strings a, b, and c each having 2*N characters each, the task is to find a string having almost 3*N characters such… Read More
Given two integers S and D, the task is to check if the integer S can be made divisible by D or not by repeatedly… Read More
Given an array arr[] consisting of N integers such that arr[i] representing the number of socks of the color i and an integer K, the… Read More
Given an arr[] consisting of N elements, the task is to count all subarrays of size K having atleast one pair whose absolute difference is… Read More
One day Ram and Shyam were searching Google for finding what is the maximum number of hairs on the human head. They found that it… Read More
Given an array of N integers, the task is to find a non-empty subset such that the sum of elements of the subset is divisible… Read More
Given an array, find the maximum difference between its two consecutive elements in its sorted form.Examples:  Input: arr[] = {1, 10, 5} Output: 5 Sorted… Read More
Given an array A[], find a subset of maximum size in which sum of every pair of elements is a prime number. Print its length… Read More
Prerequisite – The Pigeonhole Principle Problem statement – Given a 8×8 chessboard, figure out the maximum number of kings that can be placed on the… Read More
Combinatorics is the branch of Mathematics dealing with the study of finite or countable discrete structures. It includes the enumeration or counting of objects having… Read More
Also known as Gravity sort, this algorithm was inspired by natural phenomena and was designed keeping in mind objects(or beads) falling under the influence of… Read More
Suppose that a flock of 20 pigeons flies into a set of 19 pigeonholes to roost. Because there are 20 pigeons but only 19 pigeonholes,… Read More
Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key… Read More