Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
LeetCode-Style Algorithms
00:00
5 left

LeetCode-Style Algorithms

MediumPython

Problem

Nevada Staffing's Shift Planner receives scheduled worker shifts as half-open intervals [start, end). Determine the maximum number of shifts active at the same time and return the earliest time when that maximum occurs.

An interval includes its start time but excludes its end time. Therefore, a shift ending at time t does not overlap a shift beginning at time t.

Formal Specification

Implement peak_shift_overlap(shifts), where shifts is a list of two-element lists. Each interval [start, end] contains integer times with start < end. Return a two-element list [time, count], where count is the greatest number of simultaneously active shifts and time is the earliest time at which that count occurs.

Constraints

  • 1 <= len(shifts) <= 10^5
  • 0 <= start < end <= 10^9
  • Each shift contains exactly two integers
  • Intervals use half-open semantics: [start, end)
  • Return the earliest time when the maximum is reached

Function Signature

def peak_shift_overlap(shifts):
Interviewer

Your question is LeetCode-Style Algorithms. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.