//Find number of odd elements in arr
for (int i = 0; i < arr.length; i++) {
if (arr[i] % 2 != 0) oddElements++;
}
//Put odd values from arr to the resulted array
for (int i = 0; i < arr.length; i++) {
if (arr[i] % 2 != 0)
result[result_index++] = arr[i];
} //end of for loop
This is two iterations of the array. Makes it O(n2) not O(n)