Skip to main content

Array Difference

JUNIOR

Array Difference

Find elements in first array that are not in second array.

Requirements:

  • Return elements from array1 not in array2
  • Maintain original order
  • Remove duplicates from result

Example:

Input: [1,2,3,4], [2,4]
Output: [1,3]

Input: [1,2,2,3], [2]
Output: [1,3]

Examples:

Input 1:{"arr1":[1,2,3,4],"arr2":[2,4]}
Output 1:[1,3]
Input 2:{"arr1":[1,2,2,3],"arr2":[2]}
Output 2:[1,3]

Loading editor...

Run your code to see results

Click the Run button above