← SoFi Interview Insights

SoFi·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Interviewed for a software engineer role at SoFi and got a log-parsing problem that looked straightforward but had enough edge cases to keep me honest. Nothing too exotic, but the devil was in the details.

Questions Asked (1)

Q1

Given a time-ordered list of highway sensor logs (each with a timestamp, event type of ENTRY/EXIT/CHECKPOINT, and a car ID), write a function that counts the total number of completed journeys across all cars. A journey is an ENTRY followed by a later EXIT for the same car. Partial journeys and stray EXITs without a prior ENTRY don't count.

Algorithms & Data Structures
Author's notes

My first pass ignored the stray EXIT case entirely.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the logs are time-ordered and that a journey requires an ENTRY followed by a later EXIT for the same car. Then propose a single-pass solution using a hash map to track the latest unmatched ENTRY per car, incrementing a counter when a valid EXIT is found.

Pro tip: Mention that you would handle edge cases like duplicate ENTRYs (overwrite the start time) and stray EXITs (ignore them), and note that the solution is O(n) time and O(k) space where k is the number of cars.

1. Clarify requirements and assumptions

Confirm that logs are sorted by timestamp, that a journey is counted only when an EXIT follows an ENTRY for the same car, and that CHECKPOINT events are irrelevant. Ask about duplicate ENTRYs or EXITs without ENTRY.

2. Choose data structures

Use a hash map to store the latest unmatched ENTRY timestamp for each car, and a counter for completed journeys. This allows O(1) lookups and updates per log entry.

3. Process logs in one pass

Iterate through the logs in order. On ENTRY, update the map with the car's ID and timestamp. On EXIT, check if the car has an unmatched ENTRY; if so, increment the counter and remove the entry from the map.

4. Handle edge cases

Ignore EXITs without a prior ENTRY, overwrite duplicate ENTRYs (keeping the latest), and ignore CHECKPOINT events. Ensure that partial journeys (ENTRY without EXIT) are not counted.

5. Analyze complexity and test

State that time complexity is O(n) and space is O(k) where k is the number of cars. Walk through a small example to verify correctness.

Key Points to Mention

  • Time-ordered logs allow a single-pass solution without sorting.
  • Use a hash map to track the latest unmatched ENTRY per car.
  • Increment journey count only when an EXIT matches a prior ENTRY.
  • Ignore stray EXITs and CHECKPOINT events.
  • Handle duplicate ENTRYs by overwriting the start time.
  • Time complexity O(n), space complexity O(k) where k is number of cars.

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