# The One-Timers

> Values that never repeated.

Canonical URL: <https://datadriven.io/problems/the_one_timers>

Domain: Python · Difficulty: easy · Seniority: L4

## Problem

Given a dict, return the sorted list of values that appear exactly once across all entries.

## Worked solution and explanation

### Why this problem exists in real interviews

This tests **value frequency analysis and sorting**, a common pattern in data quality checks. Interviewers check whether candidates can count value occurrences across dictionary entries and filter by frequency.

---

### Break down the requirements

#### Step 1: Count how many times each value appears

Iterate through the dictionary values and build a frequency map.

#### Step 2: Filter values with count exactly 1

Collect only those values that appear once across all entries.

#### Step 3: Sort and return

Return the unique values in sorted order.

---

### The solution

**Value frequency counting with uniqueness filter**

```python
def unique_values(d):
    value_counts = {}
    for key in d:
        val = d[key]
        if val in value_counts:
            value_counts[val] += 1
        else:
            value_counts[val] = 1
    result = []
    for val in value_counts:
        if value_counts[val] == 1:
            result.append(val)
    result.sort()
    return result
```

> **Time and Space Complexity**
>
> **Time:** O(n + k log k) where n is the dictionary size and k is the number of unique values, for the final sort.
> 
> **Space:** O(n) for the frequency map.

> **Interviewers Watch For**
>
> Do you count value occurrences rather than checking key uniqueness? The values are what matter here, not the keys. Every key in a dict is already unique.

> **Common Pitfall**
>
> Confusing 'unique values' with 'distinct values'. The problem asks for values appearing exactly once, not all distinct values.

---

## Common follow-up questions

- What if you needed values appearing more than once? _(Tests inverting the filter condition.)_
- What if values were unhashable (e.g., lists)? _(Tests converting to tuples for hashing or using a different counting strategy.)_
- How would you return the keys that map to unique values? _(Tests pairing the value frequency filter with key lookup.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/the_one_timers)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.