Spent the first few minutes just restating the problem back to make sure I understood the pairing logic.
Group log entries by userId, then sort each user's entries by timestamp. For each user, scan the sorted entries, maintaining a stack of unmatched signins; when a signout is encountered, pop the most recent signin and check if the session duration is within maxTime. Collect userIds that have at least one valid session.
Pro tip: Clarify edge cases upfront: what if multiple signins occur before a signout? Typically, the most recent unmatched signin is paired (LIFO), but confirm with the interviewer. Also, mention that timestamps might need parsing and that you'll handle them as integers for simplicity.
Ask about timestamp format, whether sessions are strictly LIFO or FIFO, and if a user can have multiple valid sessions. Confirm that unmatched entries are ignored.
Use a hash map to group entries by userId, then sort each user's entries by timestamp. This ensures chronological processing.
Iterate through sorted entries, using a stack to track unmatched signins. On signout, pop the most recent signin and compute duration; if <= maxTime, mark user as having a valid session.
After processing all users, return the list of userIds that had at least one valid session.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.