← Reddit Interview Insights

Reddit·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Reddit coding screen for a software engineering role. One problem, log processing, seemed deceptively straightforward but had some tricky details around ordering.

Questions Asked (1)

Q1

You're given a long log string where each entry has the format: admin2,add,admin1(executor),timestamp. Write a function that returns a list of admin names sorted by the most recent time they were added.

Algorithms & Data Structures
Author's notes

The input format took me a second to parse mentally.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Parse each log entry to extract the added admin and timestamp, then use a hash map to track the latest timestamp for each admin. Finally, sort the admins by their latest timestamp in descending order and return the sorted list.

Pro tip: Clarify edge cases upfront, such as duplicate admin additions (keep the most recent) and invalid log entries, to show attention to detail. Also, discuss time and space complexity trade-offs, especially if the log is very large.

1. Clarify requirements and edge cases

Ask about log format consistency, handling of duplicate entries, and whether timestamps are unique or can tie. Confirm expected output order (descending by time).

2. Parse the log string

Split the log into lines, then split each line by commas to extract the added admin, action, executor, and timestamp. Validate that the action is 'add'.

3. Track latest timestamps

Use a hash map (dictionary) to store the most recent timestamp for each admin. Update the timestamp if a newer one is found.

4. Sort admins by timestamp

Extract the keys from the hash map and sort them based on their associated timestamps in descending order.

5. Return the sorted list

Return the list of admin names in the sorted order. Optionally, discuss how to handle ties (e.g., alphabetical order).

Key Points to Mention

  • Time complexity: O(n + m log m) where n is number of log entries and m is number of unique admins.
  • Space complexity: O(m) for the hash map and sorted list.
  • Handling duplicate admin additions by keeping the latest timestamp.
  • Parsing efficiency: using split or regex, and considering large input streaming.
  • Edge cases: empty log, malformed entries, ties in timestamps.
  • Choice of data structures: hash map for O(1) updates, sorting algorithm for final order.

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