Given a number N. Find the smallest even number greater than N such that the digits are a permutation of the number N. A trivial solution to start with would be to generate all the permutations of digits of the given number and then sort all the permutations. The first even permutation in the sorted […]
Tag Archives: next permutation
Given n and k, return the k-th permutation sequence of permutations of numbers {1,2,..,n}. Note: Given n will be between 1 and 9 inclusive. By listing and labeling all of the permutations in order, we get the following sequence (ie, for n = 3): “123” “132” “213” “231” “312” “321” Then, k=5th permutation sequence will […]