class Solution {
public List
List
for(int i = left; i <= right; i++) {
if(isIn(i)) {
ans.add(i);
}
}
return ans;
}
private boolean isIn(int num) {
char[] theInt = String.valueOf(num).toCharArray();
//先转成字符串,再变成字符数组
for(int i = 0; i < theInt.length; i++) {
int temp = theInt[i] - ‘0‘;
if(temp == 0) return false; //题目中说了数字中不允许出现‘0’,这里是个坑
if(num % temp != 0) return false;
}
return true;
}
}
leetcode 728. Self Dividing Numbers
原文:https://www.cnblogs.com/huangming-zzz/p/10660162.html