1429. First Unique Number

Design a data structure that supports:

  • Solution(nums): Initialize the stream with nums.
  • showFirstUnique(): Return the first number in the stream that appears exactly once, or -1 if none exists.
  • add(value): Append value to the stream.

A number is unique if its total frequency in the stream is exactly one.

Examples
Input: [["Solution","showFirstUnique","add","showFirstUnique","add","showFirstUnique","add","showFirstUnique"],[[[1,2,1,3,10]],[],[4],[],[2],[],[5],[]]]
Output: [null,2,null,2,null,3,null,3]
Hints
Related Problems

1429. First Unique Number

Design a data structure that supports: