Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Deduplicate JSON Task Events

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Deduplicate JSON Task Events. Start with the requirements on the right.

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.

Problem

Given a list of JSON strings, each representing a task event with fields task_id, status, and timestamp, write a function that returns a list of parsed task objects after removing duplicates. Two events are duplicates if they have the same task_id and status; keep only the one with the greatest timestamp. Ignore invalid JSON entries or entries missing any required field.

Constraints

  • 1 <= len(events) <= 10^4
  • Each input element is a string
  • timestamp is an integer when present
  • task_id and status are non-empty strings when present

Function Signature

def deduplicate_events(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output