Hash map · Easy
A diagnostic stream contains integer event codes, including repeated deliveries. A support tool highlights the earliest event whose code occurs only once in the entire stream. Earliest refers to arrival order, not numeric code order.
Return the first event value that occurs exactly once across the complete input stream.
Input
Call
- Implement solve(input) and return the result. The provided adapter handles JSON input and output.
Input shape
{ nums: integer[] }
Fields
- nums is an array of signed integers in its original order. Equal values at different indexes are separate entries.
Output
Return value
- Return the value, not its index. Return null when no unique value exists.
- A value repeated later is not unique even if its first occurrence was early.
Constraints
- 0 <= nums.length <= 100000; -1000000000 <= nums[i] <= 1000000000.
- All requested totals and counts fit exactly in a safe JSON integer.
Examples
Example 1
{
"nums": [
8,
2,
8,
5
]
}Returns
2Example 2
{
"nums": [
0,
3,
3
]
}Returns
0Required complexity
O(n) expected time and O(n) space