Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Prioritizing Bugs by Severity

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

Your question is Prioritizing Bugs by Severity. 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

Commvault Command Center displays defects that QA engineers must review in a consistent order. Implement a function that ranks defects by severity first, impact second, and creation time third.

Formal Specification

Write prioritize_defects(defects), where defects is a list of dictionaries. Each dictionary contains:

  • id: a unique string identifying the defect
  • severity: one of "Critical", "High", "Medium", or "Low"
  • impact: one of "Widespread", "Major", "Limited", or "Minimal"
  • created_at: a non-negative integer timestamp, where a smaller value means the defect was created earlier

Return a list of defect IDs ordered by these rules:

  1. Higher severity appears first: Critical, High, Medium, Low.
  2. For equal severity, higher impact appears first: Widespread, Major, Limited, Minimal.
  3. For equal severity and impact, older defects appear first, based on smaller created_at.
  4. If all three values are equal, preserve the original input order.

Do not modify the input list or its dictionaries.

Constraints

  • 0 <= len(defects) <= 10^5
  • Every defect contains id, severity, impact, and created_at
  • severity is one of Critical, High, Medium, or Low
  • impact is one of Widespread, Major, Limited, or Minimal
  • Defect IDs are unique
  • created_at is a non-negative signed 64-bit integer

Function Signature

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