Problem of the Day
A new programming or logic puzzle every Mon-Fri

Array Diff

It's hard to believe we're almost half way through July. Here's to problem #94!

Write a function that takes in two arrays of the same time and outputs the differences between the two arrays. For example:

arrayDiff([1,2,3], [3,2,1])
>> [1,3]
//[3, 1] would also be a valid response

For bonus points have the function take in a flag parameter that tells the function if it should care about order or not. In the example above if we didn't care about order than the arrays would be considered the same in which case you can return an empty array.

Permalink: http://problemotd.com/problem/array-diff/

Comments:

  • There are currently no comments. You can be first!

Content curated by @MaxBurstein