G2A Many GEOs
SHARE
TWEET

Find The Parity Outlier

MiroJoseph Apr 9th, 2020 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. My:
  2. object Parity {
  3.  
  4. def findOutlier(integers: List[Int]): Int =
  5.   if(integers.filter(x=>x%2==0).length>=2)
  6.         integers.filter(x => x % 2 != 0).head
  7.   else
  8.     integers.filter(x=>x%2==0).head
  9. }
  10.  
  11. Other:
  12. object Parity {
  13.   def findOutlier(integers: List[Int]): Int =
  14.     integers.groupBy(x => (x % 2).abs).minBy(_._2.length)._2.last
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top