Next Greater Element I I I
easy
1. Given a positive number 'n' in form of String. 2. Find the smallest number which has exactly the same digits existing in the number 'n' and is greater in value than 'n'. 3. If no such positive number exists, return -1 as string.
Constraints
1. 'n' is given in form of string.
Format
Input
Input: n = 12 Input: n = 21
Output
Output: 21 Output: -1
Example
Sample Input
132
Sample Output
213