easy +10 pts

Values that appear once

Find all integers that occur exactly once in a list, preserving original order.

Write a function `singles(nums)` that takes a list of integers `nums` and returns a new list containing only the integers that occur exactly once in `nums`, preserving the order of first appearance. - The input list may be empty. - The order of the output must match the order in which the numbers first appear in the input. - Do not modify the input list. **Input** - `nums`: a list of integers (can be empty, can contain duplicates). **Output** - A list of integers that appear exactly once in `nums`, in their original order of first appearance. **Complexity note**: Aim for O(n) time using a counting dictionary or set-based approach.

Constraints

- `0 <= len(nums) <= 10^5` - Each integer fits in Python's `int` (unbounded). - Time complexity: O(n), Space complexity: O(n) where n = len(nums).

Example

```python
>>> singles([1, 2, 3, 1, 2])
[3]
>>> singles([4, 4, 5, 6, 6, 7])
[5, 7]
>>> singles([])
[]
>>> singles([9, 9, 9])
[]
```
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Count how many times each number appears using a dictionary.
After counting, iterate through the original list and keep the first occurrence of each number whose count is exactly one.
To preserve order, avoid using a set for the final result; instead, build a list while iterating.
You can use `collections.Counter` to simplify counting.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.