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
Debug SwiftUI Task App State and Memory
00:00
5 left

Debug SwiftUI Task App State and Memory

EasyPython

Problem

Speechify's task manager records field updates for each task as they arrive. Given an unordered list of update events, reconstruct the final state of every task after applying only the latest update for each field.

Specification

Each event is a dictionary with four keys: task_id (integer), field (string), value (any JSON value), and timestamp (integer). Return a dictionary mapping each task_id to another dictionary of its final field values. For the same (task_id, field), the event with the largest timestamp wins. If two events for the same (task_id, field) have the same timestamp, the later event in the input list wins.

Constraints

  • 1 <= len(events) <= 10^5
  • 1 <= task_id <= 10^9
  • timestamp is an integer
  • field is a non-empty string
  • value is any valid JSON value
  • Each event contains exactly the keys task_id, field, value, and timestamp

Function Signature

def restore_task_state(events):
Interviewer

Your question is Debug SwiftUI Task App State and Memory. 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.