← Oracle Interview Insights

Oracle·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Oracle SWE coding round, one question the whole session. Pretty much a log parsing problem that looks easy until you actually think through the edge cases.

Questions Asked (1)

Q1

Given a list of unsorted log entries in the format 'userId action timestamp' (where action is either signin or signout), and an integer maxTime, return all userIds that have at least one valid session. A session is a matched signin/signout pair for the same user where the duration is at most maxTime. Unmatched signins or signouts should be ignored.

Algorithms & Data Structures
Author's notes

Spent the first few minutes just restating the problem back to make sure I understood the pairing logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Clarify requirements and edge cases

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.

2. Group and sort entries

Use a hash map to group entries by userId, then sort each user's entries by timestamp. This ensures chronological processing.

3. Process each user's entries

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.

4. Collect and return results

After processing all users, return the list of userIds that had at least one valid session.

Key Points to Mention

  • Time complexity: O(N log N) due to sorting, where N is total number of log entries.
  • Space complexity: O(N) for storing grouped entries and stacks.
  • Handling of multiple signins before a signout: use a stack (LIFO) to pair the most recent signin.
  • Ignoring unmatched signins or signouts: they do not form a valid session.
  • Edge cases: empty input, no valid sessions, duplicate timestamps, and large maxTime.
  • Potential optimization: if logs are already sorted by timestamp, grouping can be done in one pass without sorting each user's entries.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.