Learn
Exam

Finding Non-Overlapping Elements in Two Arrays

Difficulty
STARTER

Problem

Given two arrays numbers1 and numbers2 consisting of integer elements, write a function solution that finds the elements unique to each array, puts them in an array, sorts them in ascending order, and returns the result.


Constraints

  • Each element in numbers1 and numbers2 is an integer with an absolute value not exceeding 500.
  • Each array has unique elements, meaning cases like [1, 1, 2, 3] are not given.
  • Both arrays are not empty, and their lengths do not exceed 100.

Test Case

Test Case Number numbers1 numbers2 return
1 [1] [1] []
2 [1, 2, 3] [1, 2, 3, 4] [4]
3 [-204, -111, 0, 1, 450] [1, -204, 111, 0] [-111, 111, 450]

Explanation for Test Case 1

  • There are no non-overlapping elements between numbers1 and numbers2.

Explanation for Test Case 2

  • The non-overlapping element between numbers1 and numbers2 is 4.

Explanation for Test Case 3

  • The non-overlapping elements between numbers1 and numbers2 are -111, 111, 450.