## K difference permutation

Given two integers n and k. Consider first permutation of natural n numbers, P = “1 2 3 … n”, print a permutation “Result” such… Read More »

- Print all permutations of a string in Java
- Minimize the number of replacements to get a string with same number of 'a', 'b' and 'c' in it
- Minimum number of given operations required to convert a permutation into an identity permutation
- Arrange first N natural numbers such that absolute difference between all adjacent elements > 1
- Find the good permutation of first N natural numbers
- Number of moves required to guess a permutation.
- Find the count of sub-strings whose characters can be rearranged to form the given word
- Find the number of good permutations
- Generate original array from difference between every two consecutive elements
- Lexicographically Smallest Permutation of length N such that for exactly K indices, a[i] > a[i] + 1
- Find a permutation of 2N numbers such that the result of given expression is exactly 2K
- 3-digit Osiris number
- Find a permutation such that number of indices for which gcd(p[i], i) > 1 is exactly K
- Find the permutation p from the array q such that q[i] = p[i+1] - p[i]

Given two integers n and k. Consider first permutation of natural n numbers, P = “1 2 3 … n”, print a permutation “Result” such… Read More »

It was a very good experience to face interview at Qualcomm (Hyderabad-2016) I have attended the interview for a position of Software Engineer and My… Read More »

Given an array, an inversion is defined as a pair a[i], a[j] such that a[i] > a[j] and i < j. We are given two… Read More »

Given n distinct digits (from 0 to 9), find sum of all n digit numbers that can be formed using these digits. It is assumed… Read More »

Given two strings in lowercase, find the longest string whose permutations are subsequences of given two strings. The output longest string must be sorted. Examples:… Read More »

Given an array arr[] of size n>4, the task is to check whether the given array can be arranged in the form of Left or… Read More »

Given an array of digits of length n > 1, digits lies within range 0 to 9. We perform sequence of below three operations until… Read More »

I recently go interviewed for MakeMyTrip Developer position. I had 5 rounds: Round 1: 1) Reverse a Linked List – You should be able to… Read More »

Heap’s algorithm is used to generate all permutations of n objects. The idea is to generate each permutation from the previous permutation by choosing a… Read More »

BogoSort also known as permutation sort, stupid sort, slow sort, shotgun sort or monkey sort is a particularly ineffective algorithm based on generate and test… Read More »

Given a word, find lexicographically smaller permutation of it. For example, lexicographically smaller permutation of “4321” is “4312” and next smaller permutation of “4312” is… Read More »

A permutation, also called an “arrangement number” or “order”, is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with… Read More »

Python provide direct methods to find permutations and combinations of a sequence. These methods are present in itertools package. Permutation First import itertools package to… Read More »

Given a string, we need to print all possible palindromes that can be generated using letters of that string. Examples: Input: str = “aabcb” Output:… Read More »