
            // Step 4: Sort in ascending order all the digits 
            // to the right side of the swapped 'len-1'
            reverse(arr, min + 1, len - 1);

            // print the result
            System.out.print("The next greater number is: ");
            for (int i : arr) {
                System.out.print(i);
            }
        }
    }