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
Log Parsing for Top IPs
00:00
5 left

Log Parsing for Top IPs

EasyPython

Problem

Autodesk services need a compact way to identify clients generating unusually many failed requests. Given log lines from an Autodesk service, count requests with HTTP status codes from 400 through 599 and return the top 10 source IP addresses.

Each log line has this whitespace-separated format:

timestamp ip method path status

For example: 2026-08-29T10:15:00Z 192.0.2.10 GET /api/models 500

Return a list of [ip, failed_count] pairs ordered by descending failed-request count. If two IP addresses have the same count, order them lexicographically by IP address. Return at most 10 entries.

Formal Specification

  • Input: logs, a list of valid non-empty strings following the specified format.
  • Output: A list of two-element lists, where each pair contains an IP address string and its integer failed-request count.
  • Process each log line once. Do not count successful status codes from 200 through 399.

Constraints

  • 1 <= len(logs) <= 10^6
  • Each line contains exactly five whitespace-separated fields
  • The status code is an integer from 100 through 599
  • There may be up to len(logs) distinct IP addresses
  • IP addresses are valid IPv4 or IPv6 strings

Function Signature

def top_failed_ips(logs):
Interviewer

Your question is Log Parsing for Top IPs. 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.