First Unique Number Stream

Python Hard 2 views
Back to Questions

Problem Description

You will receive q operations: ADD x or FIRST. ADD adds number x to stream. FIRST should output the first number that has appeared exactly once so far, or -1 if none.

Input Format

First line q. Next q lines operations.

Output Format

Outputs for FIRST.

Sample Test Case

Input:
8 ADD 5 ADD 3 FIRST ADD 5 FIRST ADD 3 ADD 7 FIRST
Output:
5 3 7

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next