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
Energy Consumption Model for Body Cam
00:00
5 left

Energy Consumption Model for Body Cam

MediumSQL · PostgreSQL

Problem

The battery sizing team has developed a body cam usage procedure and tested it on a camera hooked to a power supply. Sensor data gives a list of time intervals (seconds) and the average current draw in milli-amps over each interval. Describe an object model that lets you find the total energy in milli-amp hours from time 0 to T. The list of intervals can be arbitrarily long and you may want to repeatedly query the power used at different times. Example: 0-300 125mA, 300-400 50mA, 400-550 500mA, 550-1000 20mA; total from T=0 to T=700s is 33.47mAh.

Asked in the CoderPad coding stage. Reported follow-ups: support repeated queries at different T efficiently.

Output

  1. Return one row per non-null requested time.
  2. Columns: target_seconds, total_energy_mah.
  3. Include usage through, but not beyond, each target time. Sort by target_seconds ascending, then query_id ascending.

Schema

camera_usage_intervals
ColumnTypeDescription
interval_idPKINTUnique usage interval identifier
start_secondsINTInclusive interval start measured from time 0
end_secondsINTExclusive interval end measured from time 0
average_current_maNUMERIC(10,2)Average current draw during the interval in milliamps
energy_queries
ColumnTypeDescription
query_idPKINTUnique requested-energy query identifier
target_secondsINTTime through which energy should be calculated
query_labelVARCHAR(50)Optional label for the requested time
Tablescamera_usage_intervalsenergy_queries
Interviewer

Your question is Energy Consumption Model for Body Cam. Start with the requirements and the two tables 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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.