Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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 feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Clock Hands Rotation Degrees
00:00
5 left

Clock Hands Rotation Degrees

EasyPython

Problem

A monitoring widget for Mastercard Decision Intelligence needs to report how far an analog clock's hour and minute hands have rotated from an initial time. Given the starting time and several elapsed-time queries, return the cumulative movement of both hands for every query.

The hour hand moves continuously at 0.5 degrees per minute, and the minute hand moves continuously at 6 degrees per minute. Movement is cumulative, so it is not reduced modulo 360; for example, a minute hand moving for 60 minutes travels 360 degrees.

Formal Specification

Implement clock_hand_movement(start_hour, start_minute, elapsed_minutes), where start_hour and start_minute describe a valid 12-hour clock time, and elapsed_minutes is a list of nonnegative integer durations. Return a list of pairs. For each duration t, the pair [hour_degrees, minute_degrees] contains the degrees traveled by the hour and minute hands during the first t minutes after the starting time.

The starting time affects the displayed positions but does not affect the distance traveled, so all queries use the same constant hand rates.

Constraints

  • 1 <= start_hour <= 12
  • 0 <= start_minute <= 59
  • 1 <= len(elapsed_minutes) <= 10^5
  • 0 <= elapsed_minutes[i] <= 10^9
  • Return results in the same order as the queries

Function Signature

def clock_hand_movement(start_hour, start_minute, elapsed_minutes):
Interviewer

Your question is Clock Hands Rotation Degrees. 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.