Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Avoiding Duplicate Notification Messages
00:00
5 left

Avoiding Duplicate Notification Messages

MediumPython

Problem

Implement a function to simulate push notifications for team members while preventing duplicate messages. Each notification contains a member ID, message ID, and message text. Return the notifications delivered in input order, keeping only the first notification for each member and message ID pair. Use def simulate_notifications(notifications):, where notifications is a list of dictionaries and the result has the same format.

Constraints

  • 0 <= len(notifications) <= 1000
  • Each notification contains the string keys member_id, message_id, and message
  • member_id and message_id are non-empty strings
  • message is a string
  • Return notifications in the order of their first occurrence
  • Duplicate detection uses the pair (member_id, message_id)

Function Signature

def simulate_notifications(notifications):
Interviewer

Your question is Avoiding Duplicate Notification Messages. 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
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.