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
ExperiencesCoaching
New
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
Get started
Optimize Live-Updating List Views
00:00
5 left

Optimize Live-Updating List Views

HardPython

Problem

Walk me through how you would optimize a list view that displays thousands of live-updating financial records in a Bloomberg mobile app.

Implement process_live_records(records, events). records is an ordered array of [record_id, value] pairs. Each event is either an update containing type, record_id, and value, or a viewport request containing type, start, and size. Return an array of snapshots for viewport requests in event order. Updates must modify the matching record without changing order. Use an approach that avoids scanning all records for each update.

Inputs are valid, record identifiers are unique, and updates reference existing records.

Constraints

  • 1 <= records.length <= 100000
  • 0 <= events.length <= 100000
  • Each record is [record_id, value], with unique record_id values
  • record_id is a string and value is an integer
  • Updates reference an existing record
  • 0 <= start <= records.length
  • 0 <= size <= records.length

Function Signature

def process_live_records(records, events):
Interviewer

Your question is Optimize Live-Updating List Views. 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.