Find the Busiest Hour From Driver Availability Bitmasks

Last updated: November 29, 2026

Quick Overview

Each driver's daily availability is a 24-bit integer where bit h is set if the driver is online during hour h. Return the hour with the most drivers online (smallest hour on ties) and that count.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Each driver's daily availability is a 24-bit integer where bit h is set if the driver is online during hour h. Return the hour with the most drivers online (smallest hour on ties) and that count.

A warm-up in the style of Uber's phone screen, framed around supply planning for a city's driver pool. The interviewer checks that you can read and test individual bits cleanly and that you do not convert every mask to a string.

What the Interviewer Expects
  • Clarifies bit ordering (bit 0 is midnight to 1 am)
  • Tests bits with shift and mask rather than string conversion
  • Handles ties by picking the earliest hour
  • Returns a sensible answer for an empty driver list
  • States O(24 * n) time and O(24) space
Key Topics to Cover
Bit manipulation
Bitmasks
Counting
Arrays
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you find hours where at least k drivers are online?
  • How would you count, for each driver, the longest contiguous online block?
  • What changes if availability is tracked in 15 minute slots (96 bits)?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: a list of non-negative integers, each below 2242^{24}. Output: a pair (hour, count). If there are no drivers, return (0, 0). Bits above 23 are ignored. Ties go to the earliest hour because o...

High-Level Design

Keep a 24-slot counter. For each mask, walk the set bits and increment the matching hour. Walking only set bits with mask & -mask (lowest set bit) is a nice touch: a part-time driver with three onli...


Submit Your Answer
Markdown supported