← Reddit Interview InsightsSoftware Engineer

Reddit·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Reddit SWE coding round, one problem about processing admin logs. Pretty focused session, just the one question but it had some layers to it.

Questions Asked (1)

Q1

Given a long log string where each entry follows the format 'admin2,add,admin1(executor),timestamp', write a function that returns an ordered list of admin names sorted by their most recent 'add' timestamp.

Algorithms & Data Structures
Author's notes

My first instinct was to just iterate through and track each admin's latest timestamp in a map, then sort at the end.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Parse each log entry to extract the admin name, action, executor, and timestamp. Filter for 'add' actions, then use a hash map to track the latest timestamp for each admin. Finally, sort the admins by their latest timestamp and return the ordered list.

Pro tip: Clarify the timestamp format and whether ties should be broken alphabetically. Also, consider if the log is huge—mention streaming or external sorting if memory is a concern.

1. Clarify requirements

Ask about timestamp format, tie-breaking rules, and expected input size. Confirm that only 'add' actions are considered and that the output should be sorted by most recent timestamp.

2. Parse the log

Split the log string into entries (e.g., by newline) and parse each entry into its components: admin, action, executor, timestamp. Handle potential edge cases like extra spaces or missing fields.

3. Track latest timestamps

Iterate through the parsed entries, and for each 'add' action, update a hash map with the admin as key and the maximum timestamp seen so far as value.

4. Sort and return

Extract the admins from the hash map, sort them by their latest timestamp in descending order (most recent first), and return the sorted list. If timestamps are equal, apply the tie-breaking rule (e.g., alphabetical).

Key Points to Mention

  • Time complexity: O(N log N) due to sorting, where N is the number of unique admins; parsing is O(M) where M is the number of log entries.
  • Space complexity: O(N) for the hash map and output list.
  • Handling large logs: consider streaming or external sorting if the log doesn't fit in memory.
  • Timestamp comparison: ensure timestamps are parsed correctly (e.g., as integers or datetime objects) for accurate sorting.
  • Edge cases: empty log, no 'add' actions, duplicate timestamps, and admins with multiple 'add' entries.
  • Tie-breaking: define a secondary sort key (e.g., admin name) if timestamps are equal.

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