Users with a Short Sign-In Session
Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure this LinkedIn problem hinges on is a plain hash map, and that's the whole trick. The September 2026 report is a log-parsing question: pair each SIGNIN with its SIGNOUT per user, then return the sorted ids with at least one session at or under maxTime. It looks like a string problem but it's a hash-table problem. If the OA invite is sitting in your inbox, you can solve this in about ten minutes once you see it. StealthCoder is the safety net if you blank mid-assessment, but the pattern is simple enough that you probably won't need it.
The problem
logs are globally sorted by increasing integer timestamp. Each entry is timestamp user SIGNIN or timestamp user SIGNOUT. Per user, sessions are well formed and non-overlapping. Return sorted user ids that have at least one session with duration at most maxTime, where duration is signout timestamp minus its paired signin timestamp. Function usersWithShortSession(logs: String[], maxTime: int) → String[] Examples Example 1 logs = ["1 alice SIGNIN","2 bob SIGNIN","5 alice SIGNOUT","12 bob SIGNOUT"] maxTime = 5 return = ["alice"] Alice's duration is 4; Bob's is 10. Example 2 logs = ["0 a SIGNIN","3 a SIGNOUT","10 a SIGNIN","20 a SIGNOUT"] maxTime = 3 return = ["a"] At least one qualifying session is sufficient. Example 3 logs = ["1 z SIGNIN","9 z SIGNOUT"] maxTime = 7 return = [] The only duration is 8. Constraints 0 <= logs.length <= 2 * 10^5. Timestamps are strictly increasing nonnegative integers. User ids have no spaces and each user's events alternate SIGNIN, SIGNOUT.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Walk the logs once. Split each line into timestamp, user, and event. On SIGNIN, store map[user] = timestamp. On SIGNOUT, compute timestamp - map[user], and if it's <= maxTime, add the user to a set. Since each user's events strictly alternate, you never need a stack or a queue, just one open signin per user. Pitfalls: using < instead of <= (Example 1 and 3 test the boundary), parsing the timestamp as a string and comparing lexicographically, and forgetting to sort the final output. Also handle empty logs, which should return an empty list. A set dedupes users with several short sessions, as in Example 2. Complexity is O(n) for the scan plus O(k log k) for sorting the result. With up to 2 * 10^5 lines, this is comfortably fast. If you freeze on parsing or the sort step, StealthCoder can hand you the working code live.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Users with a Short Sign-In Session cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass LinkedIn's OA.
LinkedIn reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Users with a Short Sign-In Session FAQ
How hard is the LinkedIn short sign-in session question really?+
Easy to medium-easy. There's no tricky algorithm. You parse lines, keep a map of open signins, and compare durations. Most failures come from off-by-one on the maxTime boundary or forgetting to sort the output ids.
What's the trick to solving it?+
Use a hash map from user to their latest SIGNIN timestamp. When a SIGNOUT arrives, subtract and compare to maxTime. Add qualifying users to a set. Sessions alternate and don't overlap, so one stored value per user is enough.
Should the comparison be less than or equal to maxTime?+
Yes. The statement says duration at most maxTime, so use <=. Example 1 has a duration of 4 against maxTime 5, and Example 3 has 8 against 7. Test a case where the duration equals maxTime exactly, since that's where strict < breaks.
How do I handle users with multiple short sessions?+
Store qualifying users in a set so each id appears once. Example 2 shows user a with a duration-3 session and a duration-10 session, and the answer is just [a]. Sort the set at the end before returning.
How do I prepare for this in 48 hours?+
Practice parsing space-separated log lines and pairing events with a hash map. Write it once in your language, handling empty input and final sorting. Then do two or three similar log-pairing problems, since this pattern shows up in many timestamp-based assessments.