# Tag Archives: permutation

Given the integers N and X, the task is to find the smallest lexicographical permutation a[], using all integers [1, N] such that a[i]%i is… Read More
Given an array A[] of size N where each element A[i] =max(P[0], P[1], . . ., P[i]), where P[] is a permutation consisting of elements… Read More
Given an array A[] of size N, find the permutation of array A such that the array B[] which is formed by taking the GCD… Read More
Given a positive integer N, the task is to construct a permutation from 1 to N such that the absolute difference of elements is in… Read More
Given a permutation of first N positive integers, the task is to form the lexicographically smallest permutation such that the new permutation does not have… Read More
Given a string str consisting of N letters, the task is to find the total number of strings that can be generated by replacing each… Read More
Given integers N and K, the task is to find the number of possible arrangements of N people around a circular table such that K… Read More
Given two integers S and X representing the sum and bitwise XOR respectively of two integers, the task is to find the count of all… Read More
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
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