Ad
  • Custom User Avatar

    Neat! Very clean.

    Unrelated: reading your solution made Big O notation make sense to me. :)

    Every item in the incoming array is processed twice, first to remove everything that's equal to or greater than zero to a fresh array, and then to sum every element of that new list. Every item is essentially touched twice so it's O squared, but technically maybe it's kind of smaller than that in an ideal case because the reducer only does its work on the resulting, probably smaller, subset of filtered numbers.

    Thanks, I know this is sort of unrelated, I just needed to go off for a sec.

  • Custom User Avatar

    yeah, you got it very well!

  • Custom User Avatar

    Testing for length first saves having to process results that deffinitely wouldn't match. Nice!