classSolution { public List<Integer> powerfulIntegers(int x, int y, int bound) { Set<Integer> set = newHashSet<>(); for (inti=1; i <= bound; i *= x) { for (intj=1; i + j <= bound; j *= y) { set.add(i + j); if (y == 1) break; } if (x == 1) break; } returnnewArrayList<>(set); } }