Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.
Example 1:
Input: 12 Output: 21
Example 2:
Input: 21 Output: -1
# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
"""
Soultions:
题目的含义是这样的:
首先我们对于当前的32为整数,找到一个所有元素都是当前元素的,并且稍微大于当前元素的整数。没有的话返回-1。
例如:
123 -> 213;
32