https://www.codewars.com/kata/5526fc09a1bbd946250002dc/train/javajava
// https://www.codewars.com/kata/5526fc09a1bbd946250002dc/train/java package codewars; public class FindOutlier{ static int find(){ int countOdd = 0; int countEven = 0; int x = 0; int[] arr = new int[2]; for(int i=0; i < integers.length; i++){ if(integers[i] % 2 == 0){ if(++countEven == 1){ arr[x++] = integers[i]; } }else{ if(++countOdd == 1){ arr[x++] = integers[i]; } } if(countOdd == 1 && countEven > 1 || countOdd > 1 && countEven == 1){ for(int j = 0; j < 2; j++){ if(countOdd == 1 && arr[j] % 2 != 0 || countEven == 1 && arr[j] % 2 == 0){ return arr[j]; } } } } return result; } }