如果一个数字十进制表达时,不存在连续两位数字相等,则称之为“不重复数”。例如,105,1234和12121都是“不重复数”,而11,100和 1225不算。给定一个long类型数字A,返回大于A的最小“不重复数”。 下面是几个测试用例
Examples:
0) 54
returns: 56
大于54的最小数字是55,但55不是“不重复数”。下一个数字是56,它满足条件。
1) 10
returns: 12
2) 9
returns: 10
3) 98
returns: 101
99和100都不是“不重复数”, 101是。
4) 21099
returns: 21201
5) 99123
returns: 101010
6) 1134567
returns: 1201010
public class GetNum {
public static void main(String[] args) {
System.out.println(getNumFunc(-1134567));
}
public static int getNumFunc(int i) {
boolean flag = true;
int j = 0;
while (flag) {
j = Math.abs(++i);
int temp1 = j % 10;
int temp2 = 0;
boolean flag2 = true;
while (j > 0) {
temp2 = temp1;
j = j / 10;
temp1 = j % 10;
if (temp1 == temp2) {
flag2 = false;
}
}
if (flag2) {
flag = false;
}
}
return i;
}
}
Output: -1098989