public static int[] fullSquare(int n) {
List<Integer> list = new ArrayList<Integer>();
for (int i = 10; i * i < n; i++) {
if (twoSame(i * i))
list.add(i * i);
}
int[] result = new int[list.size()];
for (int i = 0; i < list.size(); i++)
result[i] = list.get(i);
return result;
}
public static boolean twoSame(int n) {
Set<Integer> set = new HashSet<Integer>();
while (n > 0) {
if (set.contains(n % 10))
return true;
set.add(n % 10);
n /= 10;
}
return false;
}
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!