Ad
  • Custom User Avatar
    • [2, 0] or [0, 2] means one side of the package has a good apple, and the other side is bad.
    • [0, 0] means both sides of the package are bad, indicating a fully rotten package.
  • Default User Avatar

    you have something like: [1, -1, 6, -6, 5]
    the reduce method give the number's sum, in this case it will be 5, and this is the correct answer.
    But there is a problem maybe you have something like [1, -1, 6, -6, 5, 5], in this case the sum will be 10, because we have an additional 5, to avoid that, he has removed all the duplicated numbers in the array converting it to Set type