#K89062. Maximum Simultaneous User Sessions
Maximum Simultaneous User Sessions
Maximum Simultaneous User Sessions
You are given a log with multiple entries. Each entry has a timestamp in hh:mm:ss
format, a user ID, and an action which can either be login
or logout
. For each user, a session starts at login and ends at logout. The log entries may not be in chronological order and events that occur at the same time must be handled by processing the login
event before the logout
event.
Your task is to compute the maximum number of simultaneous (overlapping) sessions any single user has had.
Note: When two events have the same timestamp, consider the login
to occur before the logout
to ensure the maximum count is properly recorded.
inputFormat
The first line contains an integer \(n\), representing the number of log entries.
Each of the next \(n\) lines contains a log entry in the format:
hh:mm:ss user_id action
where user_id
is an integer and action
is either "login" or "logout".
outputFormat
Output a single integer representing the maximum number of overlapping sessions that any user had.
## sample6
12:01:00 1 login
12:05:00 1 logout
12:02:00 2 login
12:06:00 2 logout
12:03:00 1 login
12:07:00 1 logout
2