People in the Company
InterviewTime limit1sMemory limit256 MB
Given access-card records of enter and leave events, list the names of employees who are currently inside the office, sorted in reverse alphabetical order.
- Level
Medium4 of 10
- Topics
- Hash map, Sorting, Implementation
- Solved
- No attempts yet
Problem
Sanggeun works at Giggle, a global software company. The company's most distinctive feature is its flexible working hours, so employees are not required to be in the office from 9 to 6.
Each employee may arrive whenever they want and leave whenever they want.
Sanggeun has the log from everyone's access-card system. The log records whether a person entered (enter) or left (leave) the company. Given the log, write a program that determines everyone who is currently in the company.
Input
The first line contains , the number of access records in the log. ()
Each of the next lines contains one access record, in order: a person's name followed by either enter or leave, separated by a space. enter means arriving at work and leave means leaving work.
No two people share a name, and names that differ in letter case are considered different. Each name is a string of at most 5 uppercase and lowercase English letters.
Output
Print the names of the people currently in the company in reverse dictionary order, one per line. If no one is in the company, print nothing.