You are given an integer number. How will you find the next higher number which has the exact same set of digits as the original number? i.e , 14739642 will result 14742369 .
Example - Let the input number be 14739642 .
Time to split the number in the worst case is \( O(n) \). It requires linear time for swapping to find the correct position. Sorting requires \( O(n) \) time for reversing.
\( \therefore \) Overall Running time = \( O(n) \).