← Capital One Interview Insights

Capital One·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Capital One applied researcher interview with a pretty gnarly scheduling/simulation problem. Just the one technical question from what I can tell, but it had enough depth to keep me busy for a while.

Questions Asked (1)

Q1

You have a phone that needs t minutes of usage. You have k spare batteries, each with a known capacity (minutes of use) and recharge time (minutes to fully recharge after depletion). Only one battery powers the phone at any moment, and depleted batteries start recharging immediately but aren't available until fully recharged. Can you sustain t minutes of usage? If yes, return the total number of fully-charged battery uses; otherwise return -1. Example: capacity=[2,3,4,5], recharge=[12,8,9,10], t=100.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a minute to even parse correctly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a scheduling task where at each minute we choose the available battery with the largest remaining capacity to maximize usage. Use a max-heap to track available batteries and a min-heap to track recharging batteries, simulating the process minute by minute or event by event until t minutes are reached or no battery is available.

Pro tip: Clarify assumptions upfront: whether batteries can be swapped at any time, if recharge times are fixed regardless of usage, and if partial usage of a battery is allowed. This shows attention to detail and avoids misinterpretation.

1. Clarify problem constraints and edge cases

Confirm with the interviewer: Can we swap batteries at any minute? Are recharge times constant? Can we partially use a battery? What if t=0? This ensures alignment before coding.

2. Choose the right data structures

Use a max-heap for available batteries (keyed by remaining capacity) and a min-heap for recharging batteries (keyed by time until fully charged). This allows efficient selection of the best battery and earliest available recharge.

3. Simulate the process efficiently

Instead of minute-by-minute simulation, process events: when a battery depletes, move it to the recharge heap with its ready time; when a battery is needed, if none available, jump time to the next ready battery. Accumulate usage until t is met or no batteries remain.

4. Track total fully-charged battery uses

Count each time a battery is used from full charge (i.e., when taken from the available heap). If t is reached, return this count; otherwise return -1.

5. Test with provided example and edge cases

Walk through the example to verify the approach. Also test cases like t=0, insufficient total capacity, and batteries with very long recharge times.

Key Points to Mention

  • Greedy strategy: always use the battery with the most remaining capacity to maximize immediate usage and delay depletion.
  • Heap-based implementation for O((n + m) log n) time complexity, where n is number of batteries and m is number of swaps.
  • Event-driven simulation to avoid iterating minute by minute, improving efficiency for large t.
  • Handling of recharge times: batteries become available exactly after their recharge time from depletion.
  • Edge cases: t=0, no batteries, total capacity less than t, and batteries that never recharge in time.
  • Return value: total number of fully-charged battery uses if t is sustained, else -1.

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