Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Common Vulnerabilities

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

Your question is Find Common Vulnerabilities. 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

Aurora Innovation security tooling produces vulnerability findings for its codebase. Given a list of findings, return the k most common vulnerability types.

Each finding is a dictionary with a non-empty string type, a file, and a positive integer line. Count every finding, including multiple findings of the same type in one file. Sort the result by descending frequency. If two types have the same frequency, sort them alphabetically by type so the output is deterministic.

Return a list of dictionaries in the form {"type": vulnerability_type, "count": frequency}. If k exceeds the number of distinct types, return every distinct type.

Constraints

  • 1 <= len(findings) <= 10^5
  • 1 <= k <= 10^5
  • Each finding contains valid type, file, and line fields
  • 1 <= number of distinct types <= len(findings)

Function Signature

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