MediumPro challengePythonJavaScriptTypeScript
Array Difference
ArraysSets
Implement solve(arr, ...excluded) that returns elements of arr that
are not present in any of the excluded arrays. Preserve order and
remove duplicates from the result.
Examples
solve([1,2,3,4], [2,4])→[1,3]solve([1,2,3], [1], [3])→[2]
Sample tests
Test #1Remove elements in excluded
Input: [[1,2,3,4],[2,4]]
Output: [1,3]
Test #2Two exclusion arrays
Input: [[1,2,3],[1],[3]]
Output: [2]
Test #3Empty exclusion → original (deduplicated)
Input: [[1,2,3],[]]
Output: [1,2,3]
Test #4Duplicates in source are deduped in result
Input: [[1,1,2,2,3],[2]]
Output: [1,3]
Test #5All excluded
Input: [[1,2,3],[1,2,3]]
Output: []