Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Detecting Vulnerabilities with Scripts

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

Your question is Detecting Vulnerabilities with Scripts. 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

Tell me about a time you had to write a script to detect vulnerabilities or suspicious activity.

Implement detect_suspicious_activity(events, window_size, threshold). Each event is [timestamp, identity, action], where timestamps are integers and action is either failed_auth or another value. Return the identities with at least threshold failed-authentication events whose timestamps fit within an inclusive window of length window_size. Return identities in lexicographic order.

Input and Output

events is an unsorted list of event records. Return a list of strings.

Constraints

  • 0 <= len(events) <= 10000
  • Each event has exactly three values: timestamp, identity, and action
  • 0 <= timestamp <= 10^9
  • 1 <= window_size <= 10^9
  • 1 <= threshold <= len(events) when events is nonempty
  • identity is a nonempty string
  • action is either "failed_auth" or another string

Function Signature

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