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

# Tag Archives: Pigeonhole Principle

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 from natural phenomenons 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