← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Meta phone screen for a software engineer role. One coding question, pretty focused on edge case handling more than the algorithm itself.

Questions Asked (1)

Q1

Given a list of bus departure times as HH:MM strings and a current time string, return how many minutes have passed since the most recent bus that departed strictly before the current time. If no bus departed before the current time, return -1. A bus departing exactly at the current time does not count.

Algorithms & Data Structures
Author's notes

I jumped straight to sorting and converting everything to minutes, which was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Convert all HH:MM strings to minutes since midnight for easy comparison. Find the maximum departure time strictly less than the current time, then return the difference; if none exists, return -1. Discuss edge cases like empty list, all buses after current time, and exact matches.

Pro tip: Clarify whether the list is sorted and if there are duplicates; if sorted, a binary search can achieve O(log n) time, otherwise a linear scan is O(n). Also, confirm the expected behavior for invalid time formats or out-of-range values.

1. Clarify requirements and edge cases

Ask about input constraints: list size, sortedness, duplicates, time format validity, and whether current time can be before all departures. Confirm return value for no valid bus.

2. Choose data representation

Convert time strings to integer minutes since midnight (e.g., 'HH:MM' -> HH*60 + MM) to simplify comparisons and arithmetic.

3. Design algorithm

If list is unsorted, iterate through all times, track the maximum departure time strictly less than current time. If sorted, use binary search to find the insertion point and check the previous element.

4. Handle edge cases

If no bus departs before current time, return -1. If list is empty, return -1. Ensure exact matches are excluded.

5. Analyze complexity and test

State time and space complexity (O(n) time, O(1) space for linear scan; O(log n) for binary search if sorted). Walk through examples including edge cases.

Key Points to Mention

  • Time conversion to minutes since midnight for easy comparison
  • Strictly less than condition: exclude buses departing exactly at current time
  • Handling empty list or no valid bus by returning -1
  • Optimization: binary search if list is sorted, otherwise linear scan
  • Time and space complexity analysis
  • Edge cases: all buses after current time, duplicates, invalid input

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