Editorial for New Year's '17 P1 - Mr. N and Presents


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

The intended solution was to store a pair of <number, query number> in a deque, and to keep track of the latest query number in a map, setting to some default value (e.g. -1) upon receiving a remove command. Finally, just loop through the deque and print out the number if the query number is equal to the one stored in the map.

Time Complexity: \mathcal{O}(Q)


Comments

There are no comments at the moment.