Created
April 30, 2021 11:58
-
-
Save vrat28/0fbbc8dde677e75bed21fc6c4d2722b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Integer> powerfulIntegers(int x, int y, int bound) { | |
Set<Integer> set = new HashSet(); | |
for(int i=1; i<=bound; i*=x) { | |
for(int j=1; i+j <= bound; j*=y) { | |
set.add(i+j); | |
if(y == 1) break; | |
} | |
if(x == 1) break; | |
} | |
return new ArrayList(set); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment