Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Device Log Filtering Under Constraints
00:00
5 left

Device Log Filtering Under Constraints

MediumPython

Problem

Write a clean, testable function to filter and sort a list of device logs by timestamp and severity level under tight memory constraints.

Implement def filter_sort_logs(logs, min_severity):. Each log is a dictionary with integer timestamp and severity fields, where severity ranges from 1 to 5. Keep logs whose severity is at least min_severity, sort by ascending timestamp, then by descending severity for equal timestamps, and modify and return the original list. Use O(1) auxiliary space.

Constraints

  • 0 <= len(logs) <= 5000
  • 1 <= min_severity <= 5
  • Each log contains integer fields timestamp and severity
  • 1 <= severity <= 5
  • Timestamps fit within standard Python integers
  • The function must modify and return the original list
  • Use O(1) auxiliary space aside from the input list

Function Signature

def filter_sort_logs(logs, min_severity):
Interviewer

Your question is Device Log Filtering Under Constraints. Start with the requirements in the Question tab.

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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.