# permutation

### Find all numbers in range [1, N] that are not present in given Array

Given an array arr[] of size N, where arr[i] is natural numbers less than or equal to N, the task…

### Modify array to a permutation of consecutive numbers of longest length by at most K insertions

Given an array arr[] of length N and an integer K, the task is to find the maximize the length…

### Count of distinct permutation of a String obtained by swapping only unequal characters

Given a string find the number of unique permutations that can be obtained by swapping two indices such that the…

### Generate a permutation of first N natural numbers from an array of differences between adjacent elements

Generate a permutation of first N natural numbers from an array of differences between adjacent elementsGiven an array arr[] consisting…

### Sort a permutation of first N Natural Numbers by swapping pairs satisfying given conditions

def Swap(x, y, p, posOfCurrNum):         posOfCurrNum[p[x]], posOfCurrNum[p[y]] = posOfCurrNum[p[y]], posOfCurrNum[p[x]]    p[x], p[y] = p[y], p[x]    return p, posOfCurrNumdef sortArray(p, n):                 posOfCurrNum = [0] *…

### Count ways to place ‘+’ and ‘-‘ in front of array elements to obtain sum K

Count ways to place ‘+’ and ‘-‘ in front of array elements to obtain sum KGiven an array A[] consisting…

### Count inversions in a permutation of first N natural numbers

Count inversions in a permutation of first N natural numbersGiven an array, arr[] of size N denoting a permutation of…

### Count permutations of first N natural numbers having sum of adjacent elements equal to a perfect square

Count permutations of first N natural numbers having sum of adjacent elements equal to a perfect squareGiven a positive integer…