← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round, one algorithmic question about bus times and time arithmetic. Pretty straightforward on the surface but the edge cases tripped me up more than I expected.

Questions Asked (1)

Q1

Given a list of bus departure times in HH:MM format and a current time, find the most recent bus that has already departed. Return how many minutes ago it left, or -1 if none have passed yet.

Algorithms & Data Structures
Author's notes

Felt fine parsing the times but I fumbled on the edge case where the current time is exactly on a departure time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., list size, sortedness, time format) and then propose an efficient solution. Convert all times to minutes since midnight, find the maximum departure time that is less than or equal to the current time, and compute the difference. If no such time exists, return -1.

Pro tip: Always discuss edge cases like empty list, multiple buses at the same time, and exact matches. Also, mention that if the list is sorted, binary search can achieve O(log n) time, otherwise O(n) is optimal.

1. Clarify requirements and constraints

Ask about input size, whether the list is sorted, time format (24-hour, leading zeros), and if multiple buses can have the same departure time. Confirm the definition of 'most recent' (latest departure time that is <= current time).

2. Convert times to comparable values

Convert each HH:MM string to minutes since midnight (e.g., 14:30 -> 870) for easy arithmetic. Also convert the current time similarly.

3. Find the most recent departure

If the list is unsorted, iterate through all times to find the maximum time <= current time. If sorted, use binary search to find the insertion point and check the previous element.

4. Compute minutes ago and handle edge cases

If a valid departure is found, return current_time - departure_time. If no departure is <= current time, return -1. Consider edge cases like empty list, all buses in the future, and exact match (0 minutes ago).

5. Analyze complexity and test

State time complexity (O(n) for unsorted, O(log n) for sorted) and space complexity (O(1) extra). Walk through a few test cases to verify correctness.

Key Points to Mention

  • Time conversion to minutes since midnight for easy arithmetic
  • Handling of edge cases: empty list, no past departures, exact match
  • Time complexity: O(n) for unsorted list, O(log n) if sorted (binary search)
  • Space complexity: O(1) extra space
  • Clarifying questions about input format and constraints
  • Potential follow-up: what if the list is very large and unsorted? (consider heap or other data structures)

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