Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Minimum Alert Window Coverage

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

Your question is Minimum Alert Window Coverage. 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 alert codes alerts and a list of required alert codes required, return the shortest contiguous subarray of alerts that contains every code from required with at least the same frequency. If no such subarray exists, return an empty list. The function should return the subarray values, not the indices.

Constraints

  • 1 <= len(alerts) <= 10^5
  • 1 <= len(required) <= 10^5
  • alerts[i] and required[i] are non-empty strings
  • The sum of lengths of all strings is at most 2 * 10^5

Function Signature

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