``````public class Solution {
public static long power(long a, long b) { //my method to do Math.pow
long powerResult = 1;
while (b >= 1) {
powerResult = powerResult * a;
b--;
}
return powerResult;
}

public static long[] getNumbers(long N) {
if(N <= 1)return new long[0];
ArrayList<Long> longArrayList = new ArrayList<>();

for (long j = 1; j < N; j++) {
long numberLength = String.valueOf(j).toCharArray().length; //determine number length
char[] charArray = String.valueOf(j).toCharArray(); //charArray consists of digits (for 370 it's 3 7 0)
long sumA = 0; //initialize result of operation
for (int i = 0; i < charArray.length; i++) { //iterate over digits of input number
long sumB = 0; //initialize let's say half-result
char cyfra = charArray[i]; //get current char from array
String cyfraString = Character.toString(cyfra); //change this char to String for later purpose
int cyfraInt = Integer.parseInt(cyfraString); // now change this String to int - I don't know better solution to do this :(
sumB = sumB + power(cyfraInt, numberLength); // adding next results of power to each other
sumA += sumB; // adding to sumA to get the real result of program
}
if (sumA == j) { //check if result is the same as input number