I jumped straight to sorting and converting everything to minutes, which was fine.
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.
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.
Convert time strings to integer minutes since midnight (e.g., 'HH:MM' -> HH*60 + MM) to simplify comparisons and arithmetic.
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.
If no bus departs before current time, return -1. If list is empty, return -1. Ensure exact matches are excluded.
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.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.