Hello guys,
i'm looking to refactor this method.
It split an Array of integers int[] in two smaller ones (array1 and array2) and return those as an Object[]{array1,array2}
I'm pretty sure i can give some fresh to this algorithm.
Someone would like to review this code ?
private static Object[] inTwoSmallOnes(int[] numbers) {
int smallOnesLength = (numbers.length / 2);
int[] array1 = new int[smallOnesLength];
int[] array2 = new int[smallOnesLength];
for (int i = 0; i < numbers.length; i++) {
if (i < (numbers.length / 2)) {
array1[i] = numbers[i];
} else {
array2[i - (numbers.length / 2)] = numbers[i];
}
}
return new Object[]{array1,array2};
}
Happy coding !