101
0/304
Loading content...
You are given a compressed integer distribution in a table named Numbers:
Each row represents many repeated observations of the same value.
Your task is to compute the median of the fully expanded dataset without explicitly materializing all repeated rows.
Output requirements:
Notes:
This problem should be solved in both:
Numbers:
| num | frequency |
|-----|-----------|
| 0 | 7 |
| 1 | 1 |
| 2 | 3 |
| 3 | 1 |[
{"median": 0.0}
]The expanded distribution has 12 elements. The 6th and 7th values are both 0, so the median is 0.0.
Numbers:
| num | frequency |
|-----|-----------|
| 2 | 1 |
| 4 | 1 |
| 9 | 1 |
| 10 | 1 |[
{"median": 6.5}
]Expanded values are [2, 4, 9, 10]. Median is (4 + 9) / 2 = 6.5.
Numbers:
| num | frequency |
|-----|-----------|
| -5 | 2 |
| -1 | 3 |
| 8 | 4 |[
{"median": -1.0}
]Total count is 9, so the 5th value is the median. That position falls on num = -1.
Constraints