Given an integer N and an array arr[] of M pairs of type (Ai, Bi), the task is to generate the lexicographically smallest possible permutation… Read More

# Tag Archives: permutation

Given an integer array having N elements ranging from 1 to N and each element appearing exactly once. The task is to find the number… Read More

Given an integer N and the task is to generate a permutation of the numbers in range [1, N] such that: The GCD of all… Read More

Given two integers N, Y, generate a permutation of length N such that sum of all prefix minimum of that permutation is Y. Example: Input:… Read More

Given a binary string str of size N containing 0 and 1 only, the task is to count all possible distinct binary strings when a… Read More

Given an integer N, the task is to generate a permutation from 1 to N such that the bitwise XOR of differences between adjacent elements… Read More

Given two integers, N and K, the task is to find the number of permutations of numbers from 0 to N – 1, such that… Read More

Given an integer N, the task is to construct a permutation from 1 to N where no adjacent elements have difference as 1. If there… Read More

Given an array arr[] of N integers, the task is to find a value K such that the operation arr[ i ] = arr[ i… Read More

Given an integer N, the task is to print a permutation of numbers from 0 to N-1, such that: There is no duplicate element in… Read More

Given an integer N, consider an array having elements in the range [0, N-1] such that the maximum Bitwise XOR of all adjacent pairs is… Read More

Given two arrays a[] and b[] of length N and an integer K (1 ≤ K ≤ N). All the integers in array a[] lie… Read More