Rarest value
Your task
Given a non-empty list of integers, find the value that occurs the fewest times. If several values tie for the lowest occurrence count, return the numerically smallest of them, making the answer deterministic. For example, in [4, 4, 7, 7, 7, 2, 2] both 4 and 2 occur twice while 7 occurs three times, so the rarest values are 4 and 2 and the answer is 2. A single value list returns that value.
Examples
rarest_value(nums: list[int]) -> intExample 1
Input
rarest_value([4, 4, 7, 7, 7, 2, 2])Output
2