Convert Integer to the Sum of Two No-Zero Integers
给一个数字n, 求两个数字A和B, A+B = N 并且A和B组成的数字没有0. 这个只能一个个查.
class Solution {
public int[] getNoZeroIntegers(int n) {
for(int i = 1; i <= n/2; i++){
if(check(i) && check(n - i))
return new int[]{i, n-i};
}
return null;
}
private boolean check(int n) {
while(n != 0) {
if(n % 10 == 0)
return false;
n /= 10;
}
return true;
}
}