PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Capital One

Compute minutes since last train departure

Last updated: Mar 29, 2026

Quick Overview

This question evaluates time arithmetic and handling of cyclic day-wrap boundary conditions along with parsing and comparison of timestamp lists, reflecting skills in correct edge-case reasoning and efficient data processing.

  • hard
  • Capital One
  • Coding & Algorithms
  • Machine Learning Engineer

Compute minutes since last train departure

Company: Capital One

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Take-home Project

You are given a daily train timetable as a list of departure times (24-hour format `HH:MM`). Given the current time (also `HH:MM`), find the **most recent departure time that is not later than the current time**, and return how many minutes have elapsed since that departure. If there is **no departure earlier than or equal to the current time** on the same day, treat it as wrapping to the **previous day’s last departure**. ### Input - `departures`: list of strings, each in `HH:MM` (not necessarily sorted) - `now`: string in `HH:MM` ### Output Return: - `last_departure`: the departure time (as `HH:MM`) that most recently occurred relative to `now` - `minutes_ago`: the number of minutes between `last_departure` and `now` ### Example - `departures = ["01:10", "03:20", "05:20"]`, `now = "03:40"` - `last_departure = "03:20"`, `minutes_ago = 20` ### Constraints (assume typical interview constraints) - `1 <= len(departures) <= 10^5` - Times are valid and within a 24-hour day.

Quick Answer: This question evaluates time arithmetic and handling of cyclic day-wrap boundary conditions along with parsing and comparison of timestamp lists, reflecting skills in correct edge-case reasoning and efficient data processing.

Related Interview Questions

  • Solve Four Coding Assessment Tasks - Capital One (medium)
  • Write SQL using joins and window functions - Capital One (medium)
  • Review Preprocessing Code and Tests - Capital One (easy)
  • Remove nodes with a given value - Capital One (medium)
  • Solve multiple algorithmic interview questions - Capital One (hard)
Capital One logo
Capital One
Jan 6, 2026, 12:00 AM
Machine Learning Engineer
Take-home Project
Coding & Algorithms
3
0
Loading...

You are given a daily train timetable as a list of departure times (24-hour format HH:MM). Given the current time (also HH:MM), find the most recent departure time that is not later than the current time, and return how many minutes have elapsed since that departure.

If there is no departure earlier than or equal to the current time on the same day, treat it as wrapping to the previous day’s last departure.

Input

  • departures : list of strings, each in HH:MM (not necessarily sorted)
  • now : string in HH:MM

Output

Return:

  • last_departure : the departure time (as HH:MM ) that most recently occurred relative to now
  • minutes_ago : the number of minutes between last_departure and now

Example

  • departures = ["01:10", "03:20", "05:20"] , now = "03:40"
  • last_departure = "03:20" , minutes_ago = 20

Constraints (assume typical interview constraints)

  • 1 <= len(departures) <= 10^5
  • Times are valid and within a 24-hour day.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Capital One•More Machine Learning Engineer•Capital One Machine Learning Engineer•Capital One Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.