## Lexicographically smallest permutation with distinct elements using minimum replacements

Given an array of n positive integers such that each element of integer is from 1 to n. Find the lexicographically permutation that can be… Read More »

## Counting sets of 1s and 0s in a binary matrix

Given a n × m binary matrix, count the number of sets where a set can be formed one or more same values in a… Read More »

## Alexander Bogomolny’s UnOrdered Permutation Algorithm

The Alexander Bogomolyn’s algorithm is used to permute first N natural numbers. Given the value of N we have to output all the permutations of… Read More »

## Tile Stacking Problem

A stable tower of height n is a tower consisting of exactly n tiles of unit height stacked vertically in such a way, that no… Read More »

## Counting pairs when a person can form pair with at most one

Consider a coding competition on geeksforgeeks practice. Now their are n distinct participants taking part in the competition. A single participant can make pair with… Read More »

## Combinations from n arrays picking one element from each array

Given a list of arrays, find all combinations where each combination contains one element from each given array. Examples: Input : [ [1, 2], [3,… Read More »

## Combinations in a String of Digits

Given an input string of numbers, find all combinations of numbers that can be formed using digits in the same order. Examples: Input : 123… Read More »

## Number of Binary Trees for given Preorder Sequence length

Count the number of Binary Tree possible for a given Preorder Sequence length n. Examples: Input : n = 1 Output : 1 Input :… Read More »

## Ways to select one or more pairs from two different sets

Given two positive numbers ‘n’ and ‘m’ (n <= m) which represent total number of items of first and second type of sets respectively. Find… Read More »

## Ways to color a 3*N board using 4 colors

Given a 3 X n board, find the number of ways to color it using at most 4 colors such that no two adjacent boxes… Read More »

## Generate all passwords from given character set

Given a set of characters generate all possible passwords from them. This means we should generate all possible permutations of words using the given characters,… Read More »

## Number of compositions of a natural number

Given a natural number n, find the number of ways in which n can be expressed as a sum of natural numbers when order is… Read More »

## Cyclic Number

A cyclic number is an integer in which cyclic permutations of the digits are successive multiples of the number. The most widely known is the… Read More »

## Generate all cyclic permutations of a number

Given a number N, our task is to generate all the possible cyclic permutations of the number. A cyclic permutation shifts all the elements of… Read More »

## Print all subsets of given size of a set

Generate all possible subset of size r of given array with distinct elements. Examples: Input : arr[] = {1, 2, 3, 4} r = 2… Read More »