re: Daily Challenge #35 - Find the Outlier VIEW POST

FULL DISCUSSION
 

Dart solution:

findOutlier(List nums) {
  var odds = new List();
  var evens = new List();
  nums.forEach((num) => num % 2 == 0 ? evens.add(num) : odds.add(num));

  if (odds.length == 0 || evens.length == 0) { return null; }

  return (odds.length < evens.length ? odds : evens)[0];
}

Link to the online playground: dartpad.dartlang.org/d5e83e228c72d...

code of conduct - report abuse