Find first unique integer in a stream. | LeetCode Discuss
Design a data structure that support the following methods:
insert(int n); add integer n to a stream of integers.
getFirstUniqueInteger(); return the first unique integer in the stream if found else return -1.
Example:
for input sequence:[insert(2),getFirstUniqueInteger(),insert(2),insert(3),insert(4),getFirstUniqueInteger(),insert(3),getFirstUniqueInteger()]
output should be [2,3,4]
Read full article from Find first unique integer in a stream. | LeetCode Discuss
No comments:
Post a Comment