Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Write a Data Manipulation Function

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

Your question is Write a Data Manipulation Function. 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

Prometheus Laboratories receives alert IDs from multiple monitoring surfaces. Given a sequence of alert IDs and a minimum frequency, return every alert ID that appears at least that many times, preserving the order in which qualifying IDs first appeared.

Each occurrence contributes to the total count, and duplicate IDs must appear only once in the result.

Formal Specification

Implement filter_alerts(alert_ids, minimum_frequency). The parameter alert_ids is a list of strings, and minimum_frequency is a positive integer. Return a list of strings containing exactly the IDs whose total occurrence count is at least minimum_frequency, ordered by their first appearance in alert_ids.

Constraints

  • 0 <= len(alert_ids) <= 10^5
  • 1 <= minimum_frequency <= 10^5
  • Each alert ID is a non-empty string of at most 100 characters
  • Matching is case-sensitive

Function Signature

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