Minimum User Log
EasyHash Map · Paypal
You are given the raw activity logs of a sign-in service. Each entry is a string of three space-separated fields:
"<user_id> <timestamp> <action>"
user_idis a positive integer written without leading zeros.timestampis a non-negative integer.actionis eithersign-inorsign-out.
Every user that appears in logs has exactly one sign-in entry and exactly one sign-out entry, and the sign-out timestamp is never earlier than the sign-in timestamp. The list itself is not sorted: a user's sign-out entry may appear before their sign-in entry.
A user's session length is sign-out timestamp - sign-in timestamp. Return the ids of all users whose session length is at most maximum_time, as integers sorted in ascending numeric order. Return an empty list if no user qualifies.
Example 1
- Input:
- logs = ["30 99 sign-out", "7 5 sign-in", "100 20 sign-in", "30 40 sign-in", "7 75 sign-out", "100 45 sign-out"], maximum_time = 60
- Output:
- [30, 100]
- Explanation
- User 30 is signed in from 40 to 99 (59 units) and user 100 from 20 to 45 (25 units), both within 60; user 7 lasts 70 units and is left out. Note that user 30's sign-out appears before its sign-in in the list, and that 100 comes after 30 because ids are sorted as numbers.
Example 2
- Input:
- logs = ["4 10 sign-in", "4 10 sign-out"], maximum_time = 0
- Output:
- [4]
- Explanation
- The session lasts 0 units. The limit is inclusive, so even a limit of 0 includes user 4.
Example 3
- Input:
- logs = ["1 3 sign-in", "2 8 sign-in", "1 20 sign-out", "2 9 sign-out"], maximum_time = 5
- Output:
- [2]
- Explanation
- User 1 is signed in for 17 units and user 2 for 1 unit, so only user 2 is within 5.
Constraints
2 <= logs.length <= 10^5, andlogs.lengthis even1 <= user_id <= 10^90 <= timestamp <= 10^90 <= maximum_time <= 10^9- Each user has exactly one
sign-inand onesign-out, with sign-in time<=sign-out time