public static void main(String args[]){
        PermutationBiggerThanNumber pb = new PermutationBiggerThanNumber();
        int arr[] = {1,7,9,8,4};
        pb.nextPermutation(arr);
        for(int i=0; i < arr.length; i++){
            System.out.print(arr[i] + " ");
        }
    }
Date 02/17/2016
@author Tushar Roy
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).

Time complexity is O(n)
Space complexity is O(1)

https://leetcode.com/problems/next-permutation/
e.g 1 7 9 8 4 will transform to 1 8 4 7 9
or  4 2 6 4 3 will transform to 4 3 2 4 6
src/com/interview/number/PermutationBiggerThanNumber.java