753. Find All Non-Repeating Elements in Array

You are given an array nums consisting of n integers.

Return a list of all non-repeating elements in the array (i.e., elements that occur exactly once).

The output order does not matter.

Example 1:

Input: nums = [1, 2, -1, 1, 3, 1]

Output: [2, -1, 3]

Explanation: 1 appears 3 times. 2, -1, and 3 appear exactly once.

Example 2:

Input: nums = [1, 2, 3]

Output: [1, 2, 3]

Explanation: All elements appear exactly once.

Now Your Turn!

Pick the correct output for the given input

Input: nums =[10, 20, 10, 30, 20, 40]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= nums.length <= 10⁶
  • -10⁵ <= nums[i] <= 10⁵
0
class Solution {
public:
vector<int> findNonRepeatingElements(vector<int>& nums) {
// Your code goes here
}
};
Test Case

Input:

Nums